Adding Third-Party Ad Service Support
Third-party ad tags typically contain placeholders, known as macros, which are dynamically replaced by a Demand-Side Platform (DSP) when the ad is served. Below are the key components:
Sample Adtag:-
<iframe src='https://ad.hockeycurve.com/ad.php?zoneid=300x250&client=ideas&geo=true&tagid=18585&bcamp=j06g7x&fcat=j06g7x&partner=dbm&hct=masterv2&optout=false&dbmc=${CAMPAIGN_ID}&ct0=${CLICK_URL_ENC}&cb=${CACHEBUSTER}' frameborder='0' scrolling='no' width='300' height='250'></iframe>
1. Ad Tag Macros:
The ad tag contains macros such as:
${CLICK_URL_ENC}: A placeholder for the ad's click tracking URL.${CACHEBUSTER}: A placeholder for a random number (or timestamp in seconds) to ensure that each ad tag looks unique and avoids caching issues.${CAMPAIGN_ID}: A placeholder for the current campaign ID provided by the DSP. This helps customize the ad for the campaign and also allows tracking in analytics reports.
2. Macro Replacement by DSP:
The DSP will replace these macros with actual values when serving the ad:
- CACHEBUSTER: A random number or a timestamp in seconds that ensures each ad request is unique.
- CAMPAIGN_ID: The DSP’s current campaign ID, which can be used by the ad server to track performance and tailor the ad content.
- Click URL Macro:
-
DSP will replace
CLICK_URL_ENCin the adtag withencodeURIComponent()of click tracking url which looks similar tohttps://yourtrackingurl.com?someparameters&redirect= -
It is ending with
=at the end, where adserver will append the landing page url. (explained in point 3) -
DSP will track clicks and redirect to
redirectparam provided by adserver.
-
3. Ad server handling Final Click URL:
After replacing the macros, the ad server forms the final click URL by appending the landing page URL to the tracking URL. It then triggers a redirect, sending the user to the target page.
Example:
let final_click_url = expanded_click_macro + landing_url;
window.open(final_click_url,true);
// DSP will track clicks and redirect to `redirect` param provided by adserver.
In this example, expanded_click_macro is the fully expanded tracking URL, and landing_url is the destination URL for the ad.