One reason that Google Analytics has gained such rapid popularity is its ease of implementation. Google made the installation process easy enough that non-technical website owners have been able to use it.
For most websites, simply copying and pasting the code that Google provides is sufficient. It’s important to be able to test that code implementation immediately, though. Sometimes it’s even necessary to go back into the account to grab the code again.
Does your company keep a backup of your Google Analytics data? If not, start today.
Where is the Code?
Where Does the Tracking Code Go?
The tracking code needs to be pasted into the HTML code for each page of your website. If you use a CMS like WordPress / Joomla / Drupal, there is likely a plugin or module you can install that will insert the code automatically. If not, your web server probably has a global footer template that affects every page of your site.
Paste this code into the footer directly above the closing head tag. That said, the code loads asynchronously and can be placed anywhere in the page.
The standard implementation works for most websites. There are a few scenarios that require some modification to the tracking code before you put it into your site. If your site is an ecommerce site, uses multiple subdomains or if it spans multiple domains (e.g., during a checkout process), you will need to make some changes.
Testing the Implementation
Google Analytics may display a warning icon next to your profile indicating that the code is not set up correctly until it begins to receive data. Data can take up to 24 hours to populate, but we’ve never seen it take that long! The warning icon will go away once data begins to feed into the account. Click a few pages on your site and open the real time reports to see your traffic.
At this point, you may want to check a few things to make sure your code is implemented correctly.
Before anything else, make sure the UA number in the code is the same as the UA number for your profile. View the source of a page on your site, search for “analytics.js” (no quotes), and look for a string that looks like this:
That UA number should be identical to the one for your profile. Confirm by going to the list of your profiles in your Google Analytics account. The UA number is listed next to each one.
Google Analytics sets a few on each visitors’ machine by default. The cookie names begin with _ga. Use the browser console (press F12 on your keyboard) to view cookies created by your website – if the _ga cookies are missing, the tracking code isn’t loading correctly.
The tracking code sends all of the information to your Google Analytics account via a request to www.google-analytics.com/collect. It will have a long query string (question mark followed by variables) that contains all the pageview and visit information. You can use the Chrome, Firefox, or Internet Explorer developer console (press F12 on your keyboard) to see if the file is being requested. If it is, your code is working fine. It’s gathering all the information, setting cookies and sending it all to your account.
If the /collect request is not being made, it means the tracking code isn’t loading correctly.
Check out our Recommended Tools to learn about products that complement Google Analytics.