Set up the code to track your AdSense sites in Analytics

To see AdSense reporting in Analytics for a webpage, that webpage must contain:

In addition, if a webpage is not on your primary property, you must add a third piece of code:

Please note that the order of the code snippets is very important. The AdSense-Analytics code must be placed above the AdSense ad code.

We recommend that you place the snippets in your webpage's HTML in the following order:

  1. The Analytics tracking code, placed just before the closing </head> tag
  2. The AdSense-Analytics code snippet just after the <body> tag (for non-primary properties only)
  3. The AdSense ad code, between the <body> and </body> tags
Example code implementation

<!DOCTYPE html>



<title>Webmaster quality guidelines - AdSense Help</title>

<script type="text/javascript">

  var _gaq = _gaq || [];

  _gaq.push(['_setAccount', 'UA-XXXXX-Y']);


  (function() {

    var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;

    ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '';

    var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);






 window.google_analytics_uacct = "UA-accountnumber-propertyindex";


<h1>Webmaster quality guidelines</h1>

<p>In order to ensure a good experience for users and advertisers, publishers participating in the AdSense program are required to adhere to the webmaster quality guidelines. These guidelines provide many tips for creating sites that help Google find, index, and rank your site. In general, following these tips will help you to provide a positive experience for your users. The guidelines are quite extensive so we’ve highlighted some important information below:</p>

<script type="text/javascript"><!--

google_ad_client = "ca-pub-xxxxxxxxxxxxxxxx";

/* Homepage - 728x90 */

google_ad_slot = "2644871640";

google_ad_width = 728;

google_ad_height = 90;



<script type="text/javascript"