Rich media developer's guide

Append values or parameters to an exit URL

Objective

You want to append values to a URL based on user input or dynamic values from your creative.

This solution adds parameters to exit URLs set in Studio or Campaign Manager. If you want to use dynamic exit URLs pulled from an external data source, such as an XML feed or Google Sheet, see Use dynamic exit URLs instead.

Solution

Use an exit query string by adding the Enabler.exitQueryString() method. See the Studio HTML5 SDK reference for specifics.

An exit query string is useful when you want to send data to a landing page. For example, if you have a text field that prompts a user to submit their zip code in a creative, you can use an exit query string to pass the zip code to a landing page using the destination URL.

Studio only appends a query string to an exit URL and has no control over how that data is used on the landing page. For the query string data to function on the website, the website must be aware of the query parameters being passed in.

Examples

This article addresses two ways to use an exit query string:

You can append values to the destination URL of an exit in the standard form of a query string by using Enabler.exitQueryString(id, opt_queryString) instead of Enabler.exit(). You enter the base URL in the Studio Web UI just as you would a standard exit event. The queryString parameter is added to the end of the URL.

With this method, Studio automatically detects whether the URL you entered has a query string already and chooses a “?” or an “&” as the separator accordingly. So you don’t have to manually add a separator in your string query value in your creative.

Learn more about how Studio chooses a “?” or “&” in an exit query string

This is a basic example of the call you would make to populate your URL with the value of a variable theaterVar and the resulting complete URL, including the Studio-added punctuation character.

Enabler.exitQueryString("Buy Tickets","venue="+theaterVar);
If the URL for "Buy Tickets" is https://www.yoursite.com/purchasetickets.html, then the output would be: https://www.yoursite.com/purchasetickets.html?venue=thecoliseum

Since the URL you entered in Studio doesn't already have a query string, Studio chooses to append the value with a “?”. However, If the URL for "Buy Tickets" is https://www.yoursite.com/purchasetickets.html?showid=1234, then the output would be:

https://www.yoursite.com/purchasetickets.html?showid=1234&venue=thecoliseum

Since the URL you entered in Studio already includes a query string, Studio chooses to append the value with a “&”.

Append user input to an exit URL

To append a user’s zip code information from an input text field in your creative to a landing page, follow this example:

var zipCode = document.getElementById("zipcode").value;

function zipExitHandler() {

  // For example, if "10023" is in a text field with id "zipcode".
  Enabler.exitQueryString("my zip exit", "zip="+ zipCode);
}

exitBtn.addEventListener('click', zipExitHandler, false);

In Studio, if you enter the URL http://www.purchasetickets.com for my zip exit, the output would be:

http://www.purchasetickets.com?zip=10023
Append key-value pairs to an exit URL

To append the values loc and name that are set by a trafficker or a site to a landing page, follow this example:

The values loc and name will have to be accessed using the Studio method Enabler.getParameter(). To learn more about the method, see the Studio HTML5 SDK documentation.


var locVar = Enabler.getParameter("loc");
var nameVar = Enabler.getParameter("name");

function onKeyValueExitHandler() {
  Enabler.exitQueryString(
      "my key value exit",
      "loc="+locVar+"&name="+nameVar);
}

exitBtn.addEventListener('click', onKeyValueExitHandler, false);

In Studio, if you enter the URL http://www.purchasetickets.com for my key value exit, and the key-value is set as “madison” for loc and “mraz” for name, then the output would be:

http://www.purchasetickets.com?loc=madison&name=mraz
Was this helpful?
How can we improve it?