Adding the Tracking Code to your Pages

Google Analytics only tracks pages that contain the Google Analytics tracking code. You'll need to add this code to each page of your site, either manually or through the use of includes or other methods.

Context

To access your tracking code:

Procedure

  1. Sign in to Google Analytics.
  2. From the Analytics Settings page, find the profile for which you would like to retrieve the tracking code. Please note that tracking code is profile-specific.
  3. From that profile's Settings column, click Edit.
  4. At the top right of the Main Website Profile Information box, click Check Status.
    Your tracking code can be copied and pasted from the text box in the Instructions for adding tracking section.

Basic Installation

Context

The steps for a basic installation are as follows:

Procedure

  1. Copy and paste the code segment into the bottom of your content, immediately before the </body> tag of each page you are planning to track. If you use a common include or template, you can enter it there.
    <script type="text/javascript">
    			var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
    			document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
    			</script>
    			
    			<script type="text/javascript">
    			var pageTracker = _gat._getTracker("UA-xxxxxx-x");
    			pageTracker._initData();
    			pageTracker._trackPageview();
    			</script>
  2. You'll need to update the "xxxx-x" in the sample above with your own Google Analytics account number. You can access your personalized tracking code in its entirety by following the instructions in Where can I find my tracking codeInformation published on non-SAP site ?
    Once you've completed this step, Google Analytics will begin collecting traffic data. You'll be able to see data in your reports within 24 hours.

Database Driven Sites

Context

For database driven sites

Procedure

Insert the tracking code on your index.php page or equivalent (eg. default.php, index.cfm).

Pages with Frames

A web page containing frames will generate multiple pageviews: one for the framing page (containing either a FRAMESET or IFRAME tag within its HTML code), and one for each page shown in a frame. As a result, pageviews may be somewhat inflated. Even if a page on your site only appears as a frame for another page, we still recommend tagging it with the entire tracking code. If a visitor reaches the page through a search engine or a direct link from another site and the page doesn't contain the tracking code, the referral, keyword and/or campaign information from the source will be lost.

Please see How do I interpret the reports for a website that has framesInformation published on non-SAP site ?

Linking with Your AdWords Account

For AdWords advertisers, Google Analytics can currently import cost data from AdWords campaigns. To link your AdWords and Analytics accounts, log in to your AdWords account and follow the steps provided under the Analytics tab.