Search
Clear search
Close search
Google apps
Main menu
true

How to use dynamic exit URLs

Objective

Use an exit URL from an external data source (such as Google Sheets, an XML feed, or Google Merchant Center) instead of entering it in DoubleClick Studio, DCM or DFP.

Solution

The Enabler.exitOverride(id, url) method from the Studio HTML5 SDK overrides any exit URL entered in Studio, DCM, or DFP.

Examples

Set up a string variable, exitURL, to hold the destination URL in your creative. The URL can be hard-coded, passed in dynamically through XML, or sourced from dynamic content in rich media dynamic creatives.

Exit URL from a dynamic feed example

// Replace the dynamicContent value below with your own dynamic element value.
var exitURL = dynamicContent.Feed_1[0].ExitURL.Url;

function exitClickHandler() {
  Enabler.exitOverride("exit name goes here", exitURL);
}

exitButton.addEventListener('click', exitClickHandler, false);

Hard-coded exit URL example

var exitURL = "http://www.yoursite.com";

function exitClickHandler() {
  Enabler.exitOverride("exit name goes here", exitURL);
}

exitButton.addEventListener('click', exitClickHandler, false);

Add values or parameters to dynamic exit URLs

Add third-party tracking to dynamic exit URLs with an additional method in your creative's JavaScript code to retrieve parameters set in DCM. Use the Enabler.getParameter method to get the landing page suffix value (stored in the exit_suffix macro) and append it to exit URLs from an associated dynamic feed.

Step 1: Add code to your creative

Using one of the options below, add code to your creative to combine the dynamic exit URL with the suffix from DCM.

Combine the dynamic exit URL and suffix in Google Web Designer

  1. Click the Tap Area where you want to apply the dynamic exit and suffix to.
  2. Add a new event (click the "+" button on the events panel).
  3. Select Tap Area > Touch/Click on the Event step.
  4. On the Action step, select Custom > Add custom action Add custom action
  5. Add a function name, then paste the following custom code in the text area. Replace the example exit URL with your own exit URL.
  6. Click OK.
// Replace 'https://yourURL.com' with your own exit URL.
var exitURL = 'https://yourURL.com';
var urlSuffix = Enabler.getParameter('exit_suffix'); 
var symbol = (exitURL.indexOf('?') > -1) ? '&': '?'; 
if (urlSuffix) { 
  while (urlSuffix.charAt(0) == '?' || urlSuffix.charAt(0) == '&') { 
    urlSuffix = urlSuffix.substring(1); 
  } 
  if (urlSuffix.indexOf('?') > -1) { 
    urlSuffix = urlSuffix.replace(/\?/g, '&'); 
  } 
} 
exitURL = exitURL + symbol + urlSuffix;

Enabler.exitOverride('exit', exitURL);

Custom code to add a dynamic exit suffix
Combine the dynamic exit URL and suffix using JavaScript in any HTML editor

If you use an HTML editor other than Google Web Designer, use a JavaScript method like the one below to get the exit suffix from DCM. Before you can call this function, you need to load and initialize the Enabler.

function addSuffix(url, dcmParameter) { 
  var urlSuffix = Enabler.getParameter(dcmParameter); 
  var _url = ''; 

  if (url) { 
    var symbol = (url.indexOf('?') > -1) ? '&': '?'; 
    if(urlSuffix) { 
      while (urlSuffix.charAt(0) == '?' || urlSuffix.charAt(0) == '&') { 
        urlSuffix = urlSuffix.substring(1); 
      } 
      if (urlSuffix.indexOf('?') > -1) { 
        urlSuffix = urlSuffix.replace(/\?/g, '&'); 
      } 
    } 
    _url = url + symbol + urlSuffix; 
  } 
  return _url; 
} 

// Example of how you would use this function:
exitUrl = addSuffix(exitUrl, 'exit_suffix'); 

Step 2: Add the URL parameters in DCM

After adding your creative to DCM, enter the query parameters that will be appended to your exit URL by adding a landing page suffix.

Choose where to add the suffix based on where it should be applied:

  • All landing pages in all campaigns: Add the suffix in advertiser properties.
  • All landing pages in a campaign: Add the suffix in campaign properties.
  • All creatives assigned to an ad: Add the suffix in ad properties.

Set the suffix at the highest level to apply it across more creatives. You can override the suffix by setting it at a more specific, lower level. For example, if you set a suffix in your advertiser properties, any suffixes set in the campaign or ad properties will override the advertiser-level suffix.

Add a landing page suffix

  1. Open the ad, campaign, or advertiser properties, and click Landing page URL suffix
  2. Enter your full suffix in the text box. 

    Suffixes can include multiple query parameters, but must be 128 characters or less. If the field is locked (), click the lock to unlock it. Locked fields inherit from the parent by default: a locked campaign field inherits from the advertiser settings; a locked ad field inherits from the campaign settings.
  3. DCM identifies any key-value pairs in the suffix and allows you to edit them below the field as query parameters. You can choose macros or enter custom strings. To remove a key-value pair, click remove remove.

Landing page URL suffix settings in DCM

Landing page URL suffix settings and key-value editor in DCM.

Learn more about landing page suffixes in the DCM Help Center

Was this article helpful?
How can we improve it?