Firing Universal Pixels on Clicks, Links, and Other Non-Page-View Events

When you use the default Universal Pixel script, the tracking event occurs as soon as the script loads. Sometimes, you may want to trigger the tracking event when the user takes some other action, such as clicking a button or clicking a link, including in environments where you might not be able to use the Universal Pixel script, such as ads served outside the DSP.

To capture clicks in campaigns executed on the DSP, use the capture clicks feature in the campaign editor.

Method 1: Create a Redirect URL

If you want to capture an event which is a link that takes the user to another web page, you can use the Universal Pixel endpoint to form a redirect. This directs the user through Universal Pixel servers first and then redirects them to the destination.

This method is the most straightforward to implement and can be used in cases where you cannot use JavaScript.

  1. Get the Image Tag code for your Universal Pixel (ActionsGet Tags):

    <img src="" width="1" height="1" style="position: absolute; left: -150px;" />
  2. Extract the endpoint URL, shown in bold above.

  3. Modify the URL by passing key-value pairs as described in the Reserved Keys section of the Universal Pixel Script article. Add a "?" to the URL followed by any key-value pairs that you want to include, each one separated by a "&". The final key-value pair should be "r=REDIRECT_DESTINATION", where REDIRECT_DESTINATION is the location you want to direct the user to. Make sure that any values are URL encoded. For example:

    In this example, "cntr_url" is set to inform us that the current page URL is "", and "r" is set to instruct that the user should be redirected to "".

    If you do not include the cntr_url parameter, page URL detection will likely not work successfully. You can still use other types of rules based on any key-value pairs that you supply.

Method 2: Call the UP Tracking Function

You can separate the loading of the “up.js” script from the calling of the cntrUpTag.track() function. For example, you can load just the “up.js” script in the HEAD or BODY section of the page and call cntrUpTag.track() when the users takes the desired action.

This method is most suitable for cases where you want to track an event which doesn't cause the user to navigate to a new page.

  1. Get a standard Script Tag for your Universal Pixel (ActionsGet Tags).

    <script src=""></script>
    <script type="text/javascript">
            cntrUpTag.track('cntrData', '1234ab5678c9d');
  2. Copy the section in bold above and paste it in the HEAD or beginning of the BODY section of the page.

  3. Call the cntrUpTag.track() function when the desired action happens (e.g. when the user clicks a button). One way to achieve this could be as follows:

    <button type="button" onclick="cntrUpTag.track('cntrData', '1234ab5678c9d')">Add to cart</button>

    There are various ways to accomplish this, and the ideal solution may vary based on how your web site is coded. Provide this information to your web developer to determine the best approach for your website.

Was this article helpful?
0 out of 0 found this helpful