One of the less common management tasks in DoubleClick for Advertisers is setting up the sites that host the placements you wish to target. Some questions have come our way recently regarding how to manage sites and when you want to use getSitesByCriteria versus getDFASites. Let’s take a second to clear this up.

There are two types of sites you will deal with in DFA:

  • Site Directory sites are accessible to everyone who can view the Site Directory. These entries contain information about the site that all DFA users share, such as whether the site accepts mobile and/or interstitial placements. You cannot use these sites directly when creating placements.
  • DFA Sites are your own personal pointer to a Site Directory site. They contain settings for interacting with this site that are specific to your account. These are the sites with which you can associate placements.

An additional DFA site has to be mapped whenever you begin creating placements for a new website for the first time. So how do you go about setting these up?

Step 1: Locate the Site Directory Entry For This Site

The first step to creating a new DFA Site is to find the site you want in the Site Directory. You can use the getSitesByCriteria operation for this. Since you cannot use Site Directory sites without mapping them to a DFA Site first, the only time you should use the getSitesByCriteria operation is when you’re looking for additional sites to map into your account. In all other instances, getDfaSites is probably the operation you’re looking for.

// Get the site service using the Google Ads APIs Client Library.
DfaSession session = new DfaSession.Builder().fromFile().build();
SiteRemote siteService = new DfaServices().get(session, SiteRemote.class);

// Get sites which match the URL you are looking for.
String targetUrl = "";
SiteSearchCriteria searchCriteria = new SiteSearchCriteria();

SiteRecordSet siteRecordSet = 

// Find the site with the exact URL.
long directorySiteId = 0;
if (siteRecordSet.getRecords().length != 0) {
  for (Site result : siteRecordSet.getRecords()) {
    if (Arrays.asList(result.getUrls()).contains(searchString)) {
      directorySiteId = result.getId();
if (directorySiteId == 0) {
  System.out.println("No site with that exact URL was found!");

If the site you need doesn’t exist in the directory, you can add it through the website interface. The API does not support adding new sites to the site directory.

Step 2: Create A New DFA Site

Using the site ID you obtained in Step 1, you can create a DFA site in your account. This is also your first opportunity to modify your personal settings for this site.

// Create a DFA site.
DfaSite dfaSite = new DfaSite();
dfaSite.setName("DFA Site for Site " + directorySiteId);

// Set any other optional parameters you want.
SiteTagSettings tagSettings = new SiteTagSettings();

// Save DFA site.
DfaSiteSaveResult saveResult = siteService.saveDfaSite(dfaSite);
long dfaSiteId = saveResult.getId();
    "DFA site with ID \"%s\" was created.%n", dfaSiteId);

// Make as many placements as you need!
Placement placement = new Placement();


The site service contains methods that you won’t typically use during trafficking administration. Once your sites are set up, the operations to retrieve DFA sites are the only ones you’ll need. If you still have any questions about creating or managing sites with the API, please visit our forum.