Learn‎ > ‎1. Get Started‎ > ‎

1. How to install Google Analytic code?

posted Mar 10, 2012, 12:08 AM by Elio Mondello   [ updated Nov 17, 2017, 3:03 AM ]

Here are the instructions for implementing Google Analytic on our website.

If you are using Google AdWords

Link it to your Google Analytics account to report on cost and click data.
Google Analytics uses a combination of JavaScript and first party cookies to gather anonymous data about your visitors.

As you set up your Google Analytic account, you will be provided with a tracking code. You’ll need to install this tracking code across all pages of
your site ou want to track immediately before the closing </head>tag:

If you need to access your tracking code later on:

  1. Click the account administration icon at the top right of your screen.
  2. On the Account Administration screen, you’ll see a table listing the accounts to which you have access. Click the account that contains
    the web property you’re interested in.  
  3. You’ll then see a table listing all the web properties for that account. Click the desired web property.
  4. On the next page, click the Tracking Code tab.
  5. This page gives you the asynchronous version of the Google Analytics Tracking Code. The asynchronous version of the tracking code allows your site to run at its fastest, so we recommend that you always use this version. Throughout this course, we use the asynchronous tracking code whenever we illustrate a tracking technique.  Traditional ga.js tracking is still used on many sites. To see the traditional ga.js syntax, navigate to the URL shown on the slide.


Be sure to replace the "x"s in the code with your unique Google Analytics account number and property index, which will be explained in the next slide.

To install the JavaScript, copy your tracking code--either the code provided during setup, or your customized snippet--and paste it into your page.

One of the main advantages of the asynchronous snippet is that you can position it at the top of the HTML document. This increases the likelihood that the tracking beacon will be sent before the user leaves the page. It is customary to place JavaScript code in the <head> section, and we recommend placing the snippet at the bottom of the <head> section for best performance.

Let’s look at the tracking code. This section of the code tells Google Analytics which account this traffic belongs to. The number immediately following the “UA dash” is your unique Google Analytics account number, and the number following the last dash is the property index. Review the lesson on accounts and profiles to learn about the property index. This section of the tracking code automatically detects secure versus non-secure pages. So, you can use the same tracking code on both https and http pages.

The tracking code that is provided to you is designed to work with most site setups. In some cases, however, you’ll need to make small updates to the tracking code on each of your pages.

For example, if you need to:
• Track multiple domains in one profile,
• Track more than one subdomain per profile, or
• Track multiple domain aliases, you should review the module on tracking domains and subdomains -- and customize your code before adding it to your pages.

If you buy keywords on Google AdWords, you can use Google Analytics to see how well your paid keywords perform in terms of conversion rates, revenue, and ROI. You can compare search result positions for each keyword and you can compare ad performance. 

To do these things, you'll need to link your AdWords account to your Analytics account. Review the module on Campaign Tracking and AdWords Integration for detailed instructions.

Urchin Software from Google is similar to Google Analytics, but Urchin runs on your own servers, whereas Google Analytics is a service hosted by Google.  

If you’ve licensed Urchin, you can run both Urchin and Google Analytics together on your site. Running Urchin and Google Analytics together gives you a great deal of flexibility and analysis capability.

You’ll need to make modifications to your tracking code. While this isn’t covered in the course,  you can learn how by following the link shown in the slide.

You can also view your webpage’s source code to verify that the tracking code is installed:
  1. Navigate your browser to any page on your site.  Right click within the browser window and select the “View Page Source” or “View Source” option in your browser. 
  2. This will open a new window that contains the source code for that page.
  3. Now search for ga.js. (From the source code menu, select “Edit” and click the “Find” option.)
  4. If you find the Google Analytics tracking code on your page, then it is likely that Google Analytics has been successfully installed on your site.