Avoid Towns and Settlements at night. You can be in the town, just in an interior cell.
As for the attacks, they happen after dark, near the gates usually. What causes the biggest issue is the attacks usually occur the same time you trigger all the commuters so the NPCs are out and about. In other words, you go outside at 7PM, the NPCs commute home near the gates, the vampires show up. So, if you want a town attack and to minimize the NPC fallout, then do this:
In a city, in an interior cell, wait until 6 PM, then again until 8 PM, then again until 10 PM. This will cycle through the commute scripts and get the NPCs home. You can see how all this works if you just wait outside for these times and you will see the NPCs doing what I describe. Of course, you want to see this before you get the DLC or make it active.Then you can go outside, get the attack and have as few NPCs involved as possible. The DG Main Quest keeps you away from most of the towns and settlements, so you can concentrate on that if you want to.
Also, you don' have to have DG active say if your starting a new character and do not want to deal with the vampires right away.