Ad tags

Ad Tags are essential components of the digital advertising ecosystem. They enable the integration of programmatic advertising, optimization of ad strategies, and measurement of ad performance. 

This article offers a comprehensive overview of ad tags, their significance, and practical examples of how to use them effectively.

What are ad tags?

Ad tags are code snippets embedded into a website’s source code, often written in JavaScript or HTML. They control the communication between the website, the ad server, and the ads displayed to users.

Ad tags serve multiple purposes:

  • Ad delivery: Ad tags send requests to the ad server and load the appropriate ad in real time
  • Targeting: They transmit user and website data to display relevant ads
  • Tracking: Ad tags capture data on ad performance, such as clicks, impressions, and conversions
  • Optimization: They allow A/B testing and header bidding implementation to maximize ad revenue
Example Google Ad Manager ad tags
Example of asynchronous ad tags from Google Ad Manager

How ad tags work

When a visitor loads the website, the ad tag is triggered and sends a request to the ad server. The server initiates a bidding process lasting just milliseconds in which advertisers’ predefined bidding algorithms compete for the ad space in real time. Afterward, the winning ad will show up in the user’s browser.

Example of a simple Google Publisher Tag (GPT):

<script async src="https://securepubads.g.doubleclick.net/tag/js/gpt.js"></script>
<script>
  window.googletag = window.googletag || {cmd: []};
  googletag.cmd.push(function() {
    googletag.defineSlot('/1234567/sports', [728, 90], 'div-1').addService(googletag.pubads());
    googletag.enableServices();
  });
</script>Code language: HTML, XML (xml)

This tag defines an ad slot for a 728×90 pixel ad and associates it with a specific category (“sports”).

Types of ad tags

Synchronous ad tags

Synchronous ad tags load simultaneously with the webpage. However, this can cause issues, as a slow ad server may delay the entire page’s loading time.

In the following example, the ad tag loads synchronously, meaning the ad server must process and send the full response to the request before the visitor can see the rest of the page content. If the ad server is slow, it can delay the entire page load, negatively affecting performance.

<script type="text/javascript"> 
 var ad = document.createElement('script'); 
 ad.src = 'https://example.com/adserver.js'document.head.appendChild(ad); 
 ad.onload = function() // Code to display the ad 
 displayAd(); 
}; 
</script>Code language: HTML, XML (xml)

Asynchronous ad tags

Asynchronous ad tags load independently of the rest of the page content, improving page load times and enhancing the user experience. Many platforms, including Google AdSense, prefer asynchronous tags.

Example of an asynchronous AdSense code:

<script async src=”https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js”></script>

Benefits of asynchronous ad tags

  • Faster load times
  • Enhanced user experience
  • Positive impact on search engine rankings
  • Greater flexibility in ad management

Header bidding and ad tags

Integrating ad tags into header bidding has revolutionized programmatic advertising efficiency. In header bidding, multiple ad servers can bid simultaneously. Ad tags transmit relevant data to bidding platforms, maximizing revenue by selling ad space to the highest bidder.

Benefits of header bidding

  • Higher revenue due to competition
  • Access to a broader network of advertisers
  • Improved transparency in auctions

Tracking and optimizing with ad tags

Ad tags are crucial for delivering (programmatic) ads, tracking user data, and optimizing ad strategies. Tools like Google Analytics provide them to monitor your ad performance and record user data.

Example of a tracking script:

<script async src="https://www.googletagmanager.com/gtag/js?id=G-XXXXXXXXXX"></script> 
<script>window.dataLayer = window.dataLayer || []; 
 function gtag(){dataLayer.push(arguments);} 
 gtag('js', new Date()); 
 gtag('config', 'G-XXXXXXXXXX'); 
</script>Code language: HTML, XML (xml)

Publishers can conduct A/B tests to determine the most effective ad formats and placements. For example, tests may reveal that in-content ads have a higher click-through rate than sidebar ads, leading to adjustments in the ad tag strategy.

How to insert ad tags in WordPress

You can manually insert ad tags in WordPress, provided you have FTP access and are comfortable working with code and modifying your WordPress files. You can insert the code directly into your theme’s header.php file. Instead of manual insertion, a more straightforward, flexible, and organized approach is to use an ad plugin like Advanced Ads. This ad manager offers user-friendly options for managing and automatically placing ad tags.

Conclusion

Ad tags are fundamental for effectively monetizing websites. They play critical roles in ad delivery, targeting, and optimization. By utilizing modern technologies like asynchronous ad tags and header bidding and integrating them with plugins like Advanced Ads, publishers can increase revenue and improve the user experience. 

Make it better

Increase your ad management skills without spending more time.
Join over 150,000 publishers and AdOpts increasing their ad revenue.