Universal Analytics is the evolution of Google Analytics. In addition to tracking mobile apps and almost any other device. Let’s tracking websites with Universal Analytics and demystify how the tracking works.
Note: if you’re a beginner, and you just want to get started, all you need to know is this: get the Universal Analytics tracking code from the Tracking Info portion of the Admin Section.
After you copy the code, past it into the HEAD section of your website. If you use some type of template just add it to the template.
Once you’ve added the tag to your site you should start to see data in the Real Time reports. Google Analytics processes data about every 4-ish hours. So the standard reports will be populated about 4 hours after the code is install. But it can sometimes take up to 24 hours for data to appear.
Using the basic tag you’ll get a lot of data including:
- Visitor count
- Number of visits
- Geographic location of your visitors
- Referral information
- Device information
For those that want a little more insight into how Universal Analytics works for a website, keep reading.
The Universal Analytics Page Tag
< script >
ga('create', 'UA-YYYYY-XX', 'cutroni.com');
< /script >;
NOTE: The tag for your site will look different. Specifically the account number, which is UA-YYYYY-XX will be different, and the domain name appearing after the account number will also be different. More on this below.
The page tag consists of two parts.
1. First, a request to the Google Analytics servers for a code library. It’s named
For you coding nerds, you’ll notice that the library has changed names, from
One difference that you can not see is that
analytics.js does NOT contain any ecommerce code. That code is stored in a separate file that you use when you track a transaction. By splitting out the ecommerce code it helps the tracking code load faster on your site and speeds up your site (a little bit).
Also notice that new tracking code is asynchronous, just like the previous tracking code. This means that your website page will load while the Google Anlaytics tracking code is loading. You don’t need to worry about the code slowing down your page and causing a bad user experience.
2. The second part of the code is a list of actions.
ga('create', 'UA-YYYYY-XX', 'cutroni.com');
There are two actions.
First Google Analytics connects this tag to your account. That’s done via the
create command. It creates something called a tracking object to connect the data that is sent to your account on the server.
Once the tracking object is create the code sends a data hit, in this case a pageview, back to Google Analytics.
You’ll also notice that the syntax has changed. There are no longer functions like
_trackPageview. Now you ‘send’ or ‘create’ hits. Each type of hit has a different commend.
To track a website add the page tag, which is ALL of the code above, to all of your pages. To get the most accurate data, you should add this code to the
HEAD section of your site.
Universal Analytics Tracking Cookies
To track users on a website Universal Analytics uses a first party cookie, just like the previous version of Google Analytics. The big difference is that Universal Analytics uses ONE cookie while the previous version uses four (and sometimes five) cookies.
This reduction of cookies means that your site should be a bit (a tiny bit) faster.
The new Universal analytics cookie is named
_ga and looks like this:
Note: Did you know you can actually rename the tracking cookie in Universal Analytics?
The main reason that there is a cookie is to identify the user. This is done by generating an anonymous, random number and storing it in the cookie. This number is sent on every hit to the Google Analytics server and is used to calculate visits, visitors and campaign metrics.
For the nerds, changing the cookie expiration is different than changing how long a duration will last. Visit duration and timeout is configured in the Admin section of Google Analytics.
It’s also important to note that this cookie will work for all of sub-domains of your website. In the previous version of Google Analytics you needed to change the code to track users across sub-domains. You do NOT need to change the code in Universal Analytics.
This can be a lot to absorb, but one more thing :)
You may want to consider using Google Tag Manager to implement Universal Analytics.
A tag management tool, like Google Tag Manager, helps you avoid any coding changes to your site. You basically manage all your tags from a handy web interface.
You can also use Google Tag Manager to track events, ecommerce transactions, etc. In general, using GTM, or any tag management tool, is strongly suggested.
If you do decide to use a tag management tool, don’t forget to consider adding a data layer.
That’s about it for the basics. But there are a lot of different types of configurations that can help you customize the data for your business. These are fodder for another post.
Justin, what are the key updates of the universal analytics tracking, apart from actual formatting of the code. I mean, regarding features. Now I can get only the changes about subdomain tracking. Any other global updates in functionality?
Justin Cutroni says
Hope that helps.