How to Implement Google Analytics

Analytics are the reason Internet marketing is so effective. When you market online, you have expansive access to any kind of data you might want, from user demographic information to time spent on page.

There are many analytic platforms you can use to monitor this data, but Google Analytics is a must. Not only is it free, but Google has you covered with an extensive and thoroughly customizable suite of analytic tools.

That being said, it requires a bit of work to set up Google Analytics in the first place, especially if you’re unfamiliar with things like HTML, Javascript, PHP, and so on. In this article, we’ll explain a few different methods to implement Google Analytics on your website, so you’ll be up and running as soon as possible!

As a disclaimer, there is a very high technical ceiling to using Google Analytics. This article covers setting it up at a basic (but extremely useful) level of functionality.

Call 888-601-5359 to speak with a strategist about digital marketing services and analytics from WebFX, or keep reading to learn how to start using Google Analytics on your site.

1. Get your tracking code

Google’s tracking code is what allows the platform to access your site’s data. To get your code, head over and log into your Google Analytics account. If you don’t already have one, they’re free to make and use!

If you just signed up for an account…

Google’s process for new accounts is pretty straightforward. After you click to sign up for analytics, you’ll arrive at a setup screen that looks like this:

Google Analytics Setup Page

Fill out the information, click “Get Tracking ID,” and accept the terms and conditions. You’ll be directed to a new page that has your tracking code front and center:

Google analytics tracking id

If you already have an analytics account…

It’s even easier! Log in, click on “Admin” at the top, and then navigate to “Tracking Info,” and finally “Tracking Code”:

How to find google analytics tracking code

2. Include the tracking code on your website

The exact protocol for this step changes based on how your website is structured and whether you’re using a CMS or not.

If your website is static HTML…

The Javascript tracking code (NOT just your Tracking ID) will need to be in the HTML of every page you want to track. The code should be placed in your header, right before the tag, to ensure it loads quickly enough to properly track everything that happens on-page.

You may have read that the code should be included at the bottom of your HTML, in the footer. This used to be true years ago, but in 2009 Google implemented their Asynchronous tracking code model. Asynchronous code loads separately from your web page, so it won’t cause any hang-ups when users load your page (and therefore can be placed in your < head >).

If your website is dynamic…

You can put the tracking code in its own include file, and then simply push it dynamically onto all of your pages through templates or by hand.

If you’re using PHP, for example, you could save your tracking code in a file named “analyticstracking.php.” Then, on each page template, you would add in the code line < ?php include_once(“analyticstracking.php”) ? >.

This will automatically place the tracking code on any page using a template that has an include line in it.

If you’re using WordPress as a CMS…

There are a few ways to integrate Google Analytics with a WordPress website.

The easiest and most common method is using a plugin. There are many plugins that simply provide a field for you to paste your tracking code into and add it to all of your pages.

3. Test your analytics code

After you’ve integrated your code into your website using one of the methods above, it’s extremely important to make sure it’s sending and receiving user data properly.

Luckily, Google makes this easy to do. Head back to the “Admin > Tracking Info > Tracking Code” area of your Google Analytics account, and look for “Status” up at the top:

Analytics tracking code testing

If it looks like the above screenshot, go ahead and click the “Send test traffic” button. If everything’s working properly, it’ll then look like this:

How to test traffic in google analytics

If the test traffic works, you know everything is set up correctly and good to go!

What to do if you run into trouble

This basic setup will work the vast majority of the time.

However, if you’re experiencing issues implementing the tracking code, it’s likely an error with the tracking code itself (maybe it wasn’t copy/pasted in its entirety), or an error relating to the architecture of your website.

If you do experience problems, check out our guide to testing if Google Analytics is working and Google’s Analytics Help page on diagnosing common problems.

Looking for professional help?

If you’re not comfortable working with HTML, PHP, and other website backend languages, it can be helpful to seek out a professional to implement Google Analytics on your website.

WebFX is a full-service digital marketing agency that’s been using Google Analytics since its inception to shape digital marketing strategies for hundreds of clients. We’d love to help you get started with Google Analytics!

Contact us today for more information or a free quote.