Tracking AdSense clicks with Google Analytics
UPDATED: there is updated version available - AdSense tracking script v2
There are quite a few adsense click tracking systems/scripts around, but i was not satistied with any of them. Partly because they were not able to track what ad units were clicked (not even mentioning specific Ads and AdLinks keywords). But also mainly because their lack of advanced reporting capabilities. I'm using Google Analytics on my sites and i really like that user interface and reports, so i was looking for a way to integrate AdSense tracking with them.
The AdSense tracking script presented here is a result of my research. You can download free astracker.js script just now. Please first read the instuctions how to install this script and how to connect is to Google Analytics.
If you are rather interested in How to interpret AdSense clicks results with Google Analytics, please also read my post Analyzing and Interpreting AdSense results with Google Analytics
Features
- Supports also Firefox browser
- Tracking of clicked ad types - Type of ad unit is tracked with click. You can also setup custom type for each ad unit on page.
- Tracking clicked URLs and Keywords - URLs or AdLinks keywords are tracked together with click.
- Support for custom ad channels - You can easily setup custom channel (type) for each ad unit.
Known limitations
These are the limitation i have faced when using this script. If you know about any other, please leave me a comment and i will add it.
- Tested and tweaked for Internet Explorer / Mozilla (Firefox) only
- The clicks are tracked only after page is fully loaded - Click tracking is initialized when page onload event occurs, so before page is fully loaded no clicks can be tracked with this javascript.
- Clicks resulting from AsLinks search results ads are not tracked - This happens on google seach server, so it's simply not possible to track those clicks.
- Keyboard "clicks" are (usually) not tracked - When tabbing and pressing enter on AdSense ad, this click won't be tracked unless mouse pointer if also in AdSense IFrame.
- Possible false keyboard clicks - This is the oposite of above. When the mouse pointer is on AdSense IFrame and the user uses TAB key to focus some of AdSense IFrames, false click could be reported.
- False click reports when using two mice - Yes, this could really happen :)) When one mouse poiter is in AdSense IFrame and document unload event occurs (for example when some (non adsene) link is clicked by second mouse), false click could be reported.
Requirements
- Presented AdSense tracking script adtracker.js
- Working AdSense account
- Google Analytics account (or profile)
- Access to tracked web page source code and some web space to store javascript tracking code to (it's small around 3.5k)
- Small knowledge of HTML to implement tracking script
How does it work?
Setup is quite simple. Small javascript file is added to your web page and that's it. This script listens for ad clicks and reports them to Google Analytics (analytics code has to be already installed in the web pages). Google Analytics interface is than used to interpret tracking results.
Compliance with Google AdSense TOS
This tracking script uses passive click monitoring and in no way alters code generated by Google AdSense. It does not interfere with Ad clicks directly, but simply listens for browser mouse and keyboard events and reports through Google Analytics tracking engine. I have reviewed AdSense TOS and did not find any issue what so ever. But if you want to be sure, go ask Google AdSense support for permittion first. Just don't expect simple Yes/No answer from them :)
Tracking Accurancy
The passive listening method used by this tracking script does not allow for 100% accurate click reporting. When compared to AdSense, my results are usually about 10-15% lower in Google Analytics goals. The limitations i know about are already mentioned in some of previous paragraphs. I would be really interested in how this script performs for you (especialy for higher traffic volumes).
Google Analytics integration
Integration with Google Analytics is achieved by manually calling urchingTracker when user clicks on AdSense Ad. Tracking script simulates virtual directory hierarchy to Google Analytics so you can use it's reporting capabilities effectively. This hierarchy always starts with /asclick directory (unless you modified this value), is followed by Ad group type or custom type(channel) name. The final thierd level of this hierarchy is AsSense ad URL address or AdLinks Keyword (note that this is not available for clicks from Firefox browser).
The example tracked URL will look like:
/asclick/336x280_as/www.DirectRelief.org
or /asclick/NavigBanner/www.DirectRelief.org (if you use custom adgroup names).
Setup procedure
The setup procedure constists of two parts. First you have to setup your web page to track AdSense clicks and report them to Google Analytics. Second part is about tweaking Google Analytics settings a bit to ease interpreting click retults.
And please be prepared to wait at least 24 hours before some AdSense tracking hits appear in your Google Analytics interface.
Web Page
- Download astracker.zip file containing all required files.
- Unzip and upload tracking javascript astracker.js somewhere to the web ideally directly to your web server.
- Add reference to this javascript to your web page directly below Google Analytics code (see the following example).
<script src="http://www.google-analytics.com/urchin.js" type="text/javascript"> </script> <script type="text/javascript"> _uacct = "UA-xxxxxx-y"; urchinTracker(); </script> </script src="/javascript/astracker.js" type="text/javascript"> </script>
- Optionally tweak the page to support custom channel reporting - see Advanced Settings for further info.
Google Analytics
This procedure is not required, but it eases access to some type of reports so it's highly recomended. I will assume you followed this procedure in the examples how to interpret tracking results.
- Log on to your Google Analytics account and open settings for desired web page by clicking Edit link.
- You should see "Conversion Goals and Funnel" pane with four goals (G1-G4). Click on the right Edit link for first goal (G1).
- Set Goal URL to "/asclick" (without quotes), Goal name to "Adsense click" (without quotes) or whatever you like and finally set this goal as active (by checking Yes option for Active Goal)
- We won't setup any Funnel Navigation so you can now scroll down to Additional settings and just make sure Case sensitive option is NOT set and Match Type is set to Head Match
- Now scroll down click Save Changes button and we are set. From now on adsense clicks on your web page will be considered goal hits in Google Analytics.
Advanced settings
This AdSense tracking script supports custom channel tracking by wrapping adsense code in HTML element with specially predefined id. If you wrap your AdSense code to HTML element with id prefixed as asc_ (AdSense Contianer), the tracker will use the remaining portion of id and report is as Ad type. So for example if you wrap AdSense HTML code in div element with id asc_NavigBanner, the tracker will use "NavigBanner" instead of default "234x60_as" when tracking clicks for this Ad group.
<div id="asc_NavigBanner"> <script type="text/javascript"><!-- google_ad_client = "pub-xxxxxxx"; google_ad_width = 160; google_ad_height = 600; google_ad_format = "160x600_as"; google_ad_type = "text_image"; google_ad_channel =""; google_color_border = "E8E7D0"; google_color_bg = "FFFFFF" google_color_link = "E58712"; google_color_url = "993333"; google_color_text = "303030"; //--></script> <script type="text/javascript" src="http://pagead2.googlesyndication.com/pagead/show_ads.js"> </script> </div>
Final URL in Google Analytics will than apear as for example /asclick/NavigBanner/www.DirectRelief.org
Using Google Analytics Reports
Google Analytics is far more powerfull when compared to AdSense reporting capabilities. But some of the reports are also possible to produce with AdSense reporting and in such cases you should always use those reports as they are 100% accurate. Also there is no actual ad revenue and eCPM tracking in Google Analytics reports so you will still have to use AdSense center for this.
How many users clicked on AdSense ads?
If you want to know absolute number of AdSense ad clicks, use Goal Tracking report (Content Optimization / Goals & Funnel Process / Goal Tracking). There you can see number of clicks graph over selected period and also total and average number of clicks.
If you're rather interested in click through rate (CTR) just use the next report Goal Conversion (Content Optimization / Goals & Funnel Process / Goal Conversion). Just note that this is different CTR as oposed to AdSense reports (it should be higher). Google Analytics shows you visitors CTR as oposed to page views CTR showed by AdSense reports.
How do I know what ad types users click the most?
As usually Google Analytics has a report prepared for you. Just navigate to Content Drilldown report (Content Optimization / Content Performance / Content Drilldown). And navigate further to asclick subtree by clicking on it's icon. Now you can see different ad types in the table and also their number of visits (unique vistitor clicks) and page views (ad clicks).
You can see on this sample picture that i have used custom channel tracking and reporting. If you navigate even further and click on concrete ad type, you can even see how different banners or AdLinks keywords perform and what are your visitors most interested in!
There are no real data on those pictures. These were taken as I was testing tracking script. But with real world data even more may be concluded...
- If you look at Pageviews and Visits numbers in the sample, they are the same. But in real world use, they will probably be different. Pageviews can be interpretted as absolute number of Ad clicks, but the number in Visits column would not count repeated clicks by single visitor.
- Avg Time is also very interesting. This is the average time the user stayed on the page (the page he was sent when clicking at the Ad) in case he then returned back to your page. You can see what Ads your users don't like and are comming back to your pages fast.
- % Exit show you how many users did not come back to your pages at all and stayed on Ad page (we are of course talking about one user visit).
It's also possible to get an overview what ads are clicked the most without navitation Content Drilldown structure. We will use Goal Verification report for that (Content Optimization / Goals & Funnel Process / Goal Verification). The sample report is visible on the following picture. There is clearly visible what Ad URL's and Ad types are clicked most.
How do I know what pages generate most clicks?
This one is also quite simple. We will use integrated goal tracking for this report. Specifically Defined Funnel Navigation and Reverse Goal Path reports (Content Optimization / Goals & Funnel Process / Defined Funnel Navigation). As we have not defined any funnel navigation path you can see the AdSense clicks directly in the first report. Note that only 5 most effective pages are displayed on screen. If you want to see all pages use text export by clicking the T button on top.
You can also use Reverse Goal Path report. There you can see what navigation paths lead to most AdSense clicks.
Google Analytics Notes
Presented were only the most basic Google Analytics reports. There is far more power hidden inside Google Analytics reporting but i want to keep this post as short as possible. So if you are interested in other reporting posibilities, please also read my other post: Analyzing and Interpreting AdSense results with Google Analytics
Thanks for this script and tutorial. I added it to my blogger.com blog. Now I just have to be patient until the data starts rolling in.