Posts Tagged ‘GATC’

Installing the Google Analytics Tracking Code

posted by Analytics Expert 6:51 AM
Sunday, November 8, 2009

Getting Started with Google Analytics

Get started with Google Analytics in three simple steps. First, sign up for a Google Analytics Account. Second, install the provided code across all pages of your site. Third, if you are using Google AdWords, link it to your Google Analytics account to report on cost and click data.

Create a New Account

There are two places you can sign up for a Google Analytics account. You can go to google.com/analytics and click the “Sign up now” link. Or, if you are already an AdWords user, you can create a new account via the “Analytics” tab in AdWords.

Google Analytics Tracking Code (GATC)

Google Analytics uses a combination of JavaScript and first party cookies to gather anonymous data about your visitors. As you set up your Google Analytics account, you will be provided with a tracking code. You’ll need to install this tracking code across all pages of your site.

Finding Your Tracking Code

If you need to access your tracking code later on, you can find it by going to “Analytics Settings”, and clicking “Edit” next to the profile. You’ll be taken to the profile settings page. Click the “Check Status” link in the top right corner to be taken to the page that contains your tracking code and brief instructions for how to install it. Notice that there are two tabs each containing a different JavaScript code snippet. One tab contains the legacy urchin.js tracking code and the other contains the new ga.js tracking code. We recommend that you install the new ga.js code in order to take advantage of new tracking features as they are released. If your site already uses the urchin.js version of the tracking code and you would like to upgrade to the ga.js version, please refer to the Google Analytics Tracking Code Migration Guide.

Choose One Version of the Tracking Code

You should not use both tracking code snippets together on any single page. Doing so can result in inaccurate report data. You can, however, migrate some pages of your site to the new tracking code while the legacy code remains on other pages. In this module, each step we describe will assume you are using ga.js, and if the step is different for urchin.js, we’ll say so and provide a link to the appropriate Help Center article. Notice that the Help Center provides separate implementation help articles for each version of the tracking code.

Understanding the Tracking Code

Let’s look at the tracking code. This section of the code automatically detects secure versus non-secure pages. However, if you are using urchin.js, you’ll need to place a SECURE tracking code version of urchin.js on the secure pages of your site. Visit the link shown on the slide for more information. (http://www.google.com/support/analytics/bin/answer.py?answer=74953) Continuing through the ga.js tracking code snippet, you’ll see a “UA dash” followed by a number. 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 module on accounts and profiles to learn about the property index.

Custom Website Setup

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.

Installing the JavaScript

To install the JavaScript, copy your tracking code–either the code provided during setup, or your customized snippet–and paste it into your page. Paste the code at the bottom of your content, before the closing body tag of the page. That way, in the unlikely event that the Google service could not be reached, your page will still load properly. Here’s a sample. To maintain tracking consistency, it is important that the code is installed across all pages of your site.

Installing the Code on a Common Footer

If your website uses a content management system or site templates, then the tracking code can easily be included in a common element such as a footer. This is a quick and efficient way to tag all of the pages on your site.

Placement of the Code

For some pages, you’ll need to paste the tracking code at the top of the page instead of at the bottom. For example, in order to track ecommerce transactions, you need to call _addTrans() and _addItem(). Since the tracking code has to be executed first, you’ll need to paste it at the top of the page — before you call _addTrans() and _addItem(). If you’re tracking across multiple domains or subdomains, you’ll need to call _link() or _linkByPost(). So, paste the tracking code at the top of the page, before you call these methods. You’ll learn about these methods in upcoming modules. If your site uses frames, add your tracking code to the head section of the frameset page and directly before the closing tag of each child frame that you want to track. If you’re using custom JavaScript functions that may conflict with the ga.js file, move the tracking code to portion of website, after meta tags and title tags.

Using GA with AdWords and Other Products

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.

Checking Reports for Data

Once you’ve installed your tracking code, it usually takes about 24 hours for data to appear in your reports. After this 24 hour period, you should see the “Receiving Data” status message that’s highlighted in the slide. But, the best way to verify that you are receiving data is to simply look at your reports. Go to the Top Content report in the Content section and make sure that you see Pageview numbers for each of your pages.

Checking Source Code

You can also view your webpage’s source code to verify that the tracking code is installed. 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. This will open a new window that contains the source code for that page.

Now search for ga.js — or urchin.js if you are using the legacy code. (From the source code menu, select “Edit” and click the “Find” option.) 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. Repeat this process across several pages on your site to make sure that your installation is complete.

Making Sure Each Page Has Tracking Code

You can also use the SiteScan tool developed by EpikOne. This tool will scan each page of your site and let you know if it finds tracking code errors. Note that this tool is developed and supported by a third party, not Google.

Watch presentation.