Search
Clear search
Close search
Google apps
Main menu

Implement the Google click macro

The Google Display Network requires that all certified third-party ad tags that host and serve creatives permit Google to dynamically generate a unique click URL and pass it through the ad tag upon each ad request. If a user clicks on the ad, the third-party vendor will make an HTTP request to the Google click URL from the user's browser in order for Google to be able to track clicks on the ad.

Learn more about how the URL is passed to the vendor

After the vendor creates a key-value pair in the ad tag, Google inserts a placeholder (or click macro) as the value. When the third-party ad tag renders in the user’s browser, Google dynamically replaces the click macro with a unique click URL. The URL contains specific information about the impression. Because the information must be unique, and dynamically generated per impression, it cannot be hard-coded into the creative.

The third-party vendor implements the click URL such that an HTTP request is made when the user clicks on the creative. Third-party tags may differ greatly in structure. The following examples demonstrate how the Google click macro can be inserted into the ad tag.

Example: JavaScript URL third-party ad tag
<SCRIPT language='JavaScript1.1' SRC="http://www.3rdpartydomain?key1=value1&key2=value2&cachebuster=[Cachebuster_Macro_Here]&click=[Google_Click_Macro_Here]"></SCRIPT>
Example: iframe URL third-party ad tag
<iframe bordercolor="#000000" frameborder="0" height="XXX" hspace="0" marginheight="0" marginwidth="0" scrolling="no" src="http://www.3rdpartydomain.com?key1=value1&key2=value2&cachebuster=[Cachebuster_Macro_Here]&
click=[Google_Click_Macro_Here]" vspace="0" width="XXX">
Example: JavaScript ad tag with macro variable

<script type="text/javascript">
  function swfver(){
    var v=0;
    v = <determine flash version>
    return v;
  }
  var d=new Date();d=d.getDay()+"|"+d.getHours()+":"+d.getMinutes()+"|"+ d.getTimezoneOffset()/60;

  var redir="[Google_Click_Macro_Here]";
  var host=(("https:"==document.location.protocol)?"https://":"http://");
  var url="www.3rdpartydomain.com/url_path/?flash="+swfver()+"&time="+d+"&redir="+redir+"&r="+Math.random();
  document.write("<scr"+"ipt type='text/javascript' src='"+host+url+"'></scr"+"ipt>")
</script>

Types of Google click macros

There are different types of click macros that Google offers. The difference between the click macros is simply how many times the characters in the click URL (where the click macro renders) has been “escaped”. The Google click URL contains a number of different key-value pairs that are delimited with characters such as “&” and “?”.

Depending on the implementation method, the Google click URL’s key-value pairs can conflict with the third-party key-value pairs that use these same delimiters. Therefore, the Google click URL may need to be “escaped” in order to eliminate any code conflicts. Here are the different click macro versions that Google offers:

Unescaped click URL: %%CLICK_URL_UNESC%%

See an example

Sample of what the macro renders to when passed through the ad tag upon ad request:

http://googleads.g.doubleclick.net/pagead/aclk?sa=l &ai=BsD-iGQbNSun3LJvqjQTg0MWeDOCtkEmu5vD7CsCNtw GQThABGAEg9084AFCAx-HEBGDJhvuGyKOQGYgBAaABzvrC_wOyARN3d3cuY29ycC5nb29nbGUuY
29tugEKMzAweDI1MF9hc8gBCdoBWWh0dHA6Ly93d3cuY29ycC5nb29nbGUuY29tL2VuZy90ZXN0aW5nL1
RTL2RvY3MvdGVzdHBsYW5zL2NhZmVfdGVzdGluZy90ZXN0XzNyZF9wYXJ0eS5odG1suAIYqAMB9QMAAAA
E9QMEAAAA&num=1&client=ca-mongoogle&adurl=

Escaped click URL: %%CLICK_URL_ESC%%

See an example

Sample of what the macro renders to when passed through the ad tag upon ad request:

http://googleads.g.doubleclick.net/pagead/aclk%3Fsa%3Dl%26ai%3DBsD-iGQbNSun3LJvqjQTg0MWeDOCtkEmu5
vD7CsCNtwGQThABGAEg9084AFCAx-HEBGDJhvuGyKOQGYgBAaABzvrC_w
OyARN3d3cuY29ycC5nb29nbGUuY29tugEKMzAweDI1MF9hc8gBCdoBWWh0dHA6Ly93d3cuY29ycC5nb29nbGUuY29tL2VuZy90ZXN0aW5nL1RTL2RvY3MvdGVzdHBsYW5zL2NhZmVfdGVzdGluZy90ZXN0XzNyZF9wYXJ0eS5odG1suAIYqAMB9QMAAAAE9QMEAAAA
%26num%3D1%26client%3Dca-mongoogle%26adurl%3D

Double-escaped click URL: %%CLICK_URL_ESC_ESC%%

See an example

Sample of what the macro renders to when passed through the ad tag upon ad request:

http://googleads.g.doubleclick.net/pagead/aclk%253Fsa%253Dl%2526ai%253DBsD-iGQbNSun3LJvqjQTg0MWeDOCtk
Emu5vD7CsCNtwGQThABGAEg9084AFCAx-HEBGDJhvuGyKOQGYgBAaABzvrC_wOyARN3d3cuY29yc
C5nb29nbGUuY29tugEKMzAweDI1MF9hc8gBCdoBWWh0dHA6Ly93d3cuY29ycC5nb29nbGUuY29tL2VuZy90ZXN0aW5nL1RTL2R
vY3MvdGVzdHBsYW5zL2NhZmVfdGVzdGluZy90ZXN0XzNyZF9wYXJ0eS5odG1suAIYqAMB9QMAAAAE9QMEAAAA%2526num%253D
1%2526client%253Dca-mongoogle%2526adurl%253D

Click URL implementation methods

Method 1: Redirect chain

The third-party vendor can create a chain of click URLs that redirect the user. A click is tracked every time the user hits a specific click URL. By industry standards, click URLs should redirect users to the appended URL. Here are the options of how the third-party can create redirect chain that the user is sent to when clicking on the ad:

  1. Third-party click URL [then append] Google click URL [then append] destination URL
    Result: Third-party’s Click URL [redirects to] Google click URL [redirects to] destination URL
  2. Google click URL [then append] third-party’s click URL [then append] destination URL
    Result: Google click URL [redirects to] third-party’s click URL [redirects to] destination URL

Pros: Some Google trafficking tools offer a feature that validates that the Google click URL was implemented properly and that clicks will be generated in Google reports. This tool only works when using the click redirect chain.

Cons: There is added latency when sending a user to the destination page after they click on the ad because of the redirects. Also, different click macro versions are needed for different third-party tags since code conflicts and character-escaping issues may occur when the Google click URLs are passed through various parameters by the third-party’s scripts and when they are appended to the third-party’s URL that contain similar delimiters. Finally, browsers (Internet Explorer, especially) have URL length limits. If the redirect string is too long, some of the characters will get cut off by the browser, and the entire redirect path will not execute properly.

Method 2: Parallel requests

Instead of forming a long redirect chain of multiple click URLs, the third-party can simply redirect the user to their own click URL and then to the destination URL. While the user is being redirecting to the third-party’s click URL, the 3rd party will make a separate client-side HTTP request to the Google click URL when the user clicks on the creative.

Pros: There is less latency when the user is redirected to the destination page since there are less redirects.

Cons: Some Google trafficking tools offer a feature that validates that the Google click URL was implemented properly and that clicks will be generated in Google reports. This tool only works when using the click redirect chain method above, however, so the click validation feature will not work with this method.

More information

Was this article helpful?
How can we improve it?