How to Set up Banner Impressions

As a website owner, webmaster or marketing manager of a site, one of your primary objectives should be to drive as much traffic to your website as possible.

But, once you start getting more traffic, you need to develop a mechanism that will empower you to track the number of views the different pages of your site get. In this way, you can prepare marketing strategies to leverage whatever views or impressions your website gains by placing different banner ads on your landing page, having a whitepaper download option in the sidebar, or having some form of sponsored or featured content.

Then, it is important to track the banner impressions or views so that you can experiment further, placing your sponsored content at different locations on your website, before finalizing the ideal location that gets the most views.

This is where the use of Google Analytics (Universal Analytics), in conjunction with Google Tag Manager (GTM), can help you as it accurately tracks the banner impressions.

Let us find out the different ways in which you can set up Google Analytics to track banner impressions.

Track the Banner Impressions through Events in Google Analytics

You can get the number of clicks as well as the number of impressions of a banner with the help of events in Google Analytics. You can also assign a value that allows you to charge a cost per impression or click, thereby giving you the opportunity to charge your site visitors or customers. By tracking the appropriate events with Google Analytics, you can even create custom reports, goals, and so on.

The sample script (for Universal Analytics) which can be used by your developer team for using events in Google Analytics is given below:

  1. //sample code below, needs to update with your values
  2. <a href="http://localhost/someurl" onClick="ga('send', 'event', 'banner', 'click','BANNERNAME',1.00, {'nonInteraction': 1});" ><img style="border: 0px" src="http://localhost/someurltoapic.jpg" alt="SOMEALTEXT" /></a>
  3. <img width=0 height=0 src="data:image/gif;base64,R0lGODlhAQABAIAAAP///////yH5BAEKAAEALAAAAAABAAEAAAICTAEAOw==" onload="ga('send', 'event', 'banner', 'impression','BANNERNAME',2.00, {'nonInteraction': 1});"/>

For the above code, your developers can:

  • Replace the URL http://localhost/someurl with the link of your website that you intend your visitors to open;
  • Interpret the next bit of code to track the event by treating the banner as a category, a click as an action, the Bannername as a label, and the value as blank or 0 or even cost per click (CPC); or
  • Interpret similar code to track the impressions.

The result of the above piece of code is a comprehensive report generated in Google Analytics for tracking clicks and impressions. With this, you can create custom reports, email reports, goals, profiles, and more which are filtered just for the banner ads.

Track the Banner Impressions through the Implementation of Macro Codes in GTM

To track the banner ads, you need not worry about the content as long as it is identifiable by an ID or class or even content name. The idea is to track the impressions as events in Universal Analytics, as soon as the web page loads. This is possible through the use of GTM, and the following piece of sample sponsored content helps:

<div id="sponsored-content" data-sp-content="paypal" data-sp-location="sidebar">
<h1>Never Miss a Transaction!</h1>
<p> 100% accuracy of paypal transactions in google analytics
<a href="">Beta Signups Open</a>

The ideal way to track the impressions is to look out for when this block appears or displays on the web page, whenever the page is loaded. For this purpose, you can include the above sample code with the Google Analytics pageview tracking code. In this way, when the web page loads, a code will run to detect the banner.

Your developer team can create a new JavaScript macro and use the function code below to detect the banner. Label this as “detect sponsored content” and include the following code in the Universal Analytics pageview tag:

return function(){
// Check if the page contains the div
var node = document.getElementById("sponsored-content"); // use whatever id your block has
isInBody = document.body.contains(node);

// If true
if (isInBody){

When the page loads, the pageview tag will be loaded, the sponsored content will be detected, and this will fire an event. Your team needs to capture this by using GTM event to trigger an event in Google Analytics.

You need to use two more custom JavaScript macros to fetch the details regarding the content name and location, thereby passing the same information to Google Analytics. Basically, it involves separately extracting the values for sponsored_content_ID, sponsored_data_spContent_name and sponsored_content_location.

The following is an example for Macro 1 for detecting the sponsored name:

var contentId = document.getElementById("sponsored-content"); // id of our sponsored block
var contentName = contentId.getAttribute("data-sp-content"); //custom attribute name

return contentName;

Similarly, Macro 2 for detecting the sponsored location can be as follows:

var contentId = document.getElementById("sponsored-content"); // id of our sponsored block
var contentLocation = contentId.getAttribute("data-sp-location"); //custom attribute name

return contentLocation;

You can dynamically populate the data with content meant for events. The objective of your developer team should be to capture all this in GTM events:

  • Event Category: sponsored impressions
  • Event Action: {{detect sponsored name}}
  • Event Label: {{detect sponsored location}}
  • Set or fix the rule for tag to {{event}} equals {spContent-detected}

This process will allow you to fire events as and when you intend to track impressions for a piece of content (either sponsored or featured). The content can be anything like a “Hello Bar” on your main homepage, a deals or offers page for your ecommerce portal, or banner ads on the sidebar.

The methods discussed in this article will help you track banner impressions for the content on your website or blog. However, these should not be tried for measuring the impressions of banners on websites that do not belong to you. Additionally, you can use a custom method, such as firing a custom metric, along with a custom dimension at the page level itself.

We hope that the above information about the ways in which you can set up data gathering of the banner content impressions on your website prove useful to you.

Have you used any of these methods to measure the impressions or clicks on your site? Feel free to share your feedback, inputs or queries in the comments section below.

If you like my articles,