The other day when I was working on my website, I had a question about whether I could embed Google Analytics into the site to collect analytics data about the web traffic the site is receiving. I’ve worked with Google Analytics before at a previous job, but only as a downstream consumer of the data, so I thought this would be an interesting exercise to get acquainted with how GA is set up and how it works.
The first thing I did was research whether Google Analytics offers a free tier. It turns out GA is a freemium service, so you can get a lot of the basic services it offers for free. This works particularly well for small companies or individual users like me. For larger companies that plan to rely heavily on web analytics metrics and have a need for more customized metrics, the paid version would be more appropriate. The paid tier is referred to as “Google Analytics 360”, and the price starts at a staggering $150,000 per year. I was mostly just interested in learning more about Google Analytics through the process of setting it up, and I was interested to see what types of data I could collect out of the box.
Initially I read through a variety of Google Analytics documentation from Google as well as other people’s articles about configuring it. There was a lot of overlap between the things I read, but it wasn’t super straightforward, so I figured I would start trying it out and learning as I went. The first thing to do is set up a Google Analytics account. I learned the hard way, before you even do this, make sure you are signed in to Google with the account that you want your GA account to be associated with, because I set mine up with the wrong email. From there it guides you through a series of steps to set up an account, which will collect data on your website. It wasn’t clear to me at first, but the “Property collection” in Step 2 is asking for the URL of your website for the “Property name”.
Once you get to the end in the “data collection” (Step 5) section, it will allow you to set up a data stream, where you can start configuring data you want to collect on your site.
When the data stream creation is finished it should display a message like this, telling you that you need to follow the tag instructions:
The tag is a piece of HTML code that you need to embed in the header tag of each of your HTML pages on your website that you want to have tracked by Google Analytics. When I first set this up, I copied this HTML block and pasted it in my header tags. After that I went to the Google Analytics console, and I was expecting to see data from me visiting the website from a browser on my phone, but it was only showing page views from my computer.
I went back to the data stream, and it still said it was not receiving data from the tag I set up. This didn’t make sense because I knew I embedded the HTML correctly in my site. Thinking I did something wrong with the tag set up in GA, I started researching Google Tag Manager. I had seen it mentioned in some blog posts I read, and I thought that could be the answer to why my site was not receiving data from my tag.
Through some research, I learned Google Tag Manager is a tool that makes it easier to change and add tags on your site without having to go in and edit the HTML tags on all your pages every time you want to modify them. It’s optional, and you can set up Google Analytics without it. Similar to the step above, you have to create a separate account for Google Tag Manager and then configure it to point to your website. GTM will give you tags, like Google Analytics, except there is a tag that needs to go in the header tag and another one in the body tag in your HTML. You need to configure the Google Tag Manager tag to point to the data stream created in Google Analytics, but then you don’t have to do anything else with the tag generated by Google Analytics.
Getting things setup with Google Tag Manager still didn’t resolve the message in Google Analytics saying that my data stream was not receiving data, so I spent some time trying to figure out why it said it still wasn’t working. I found out that it takes between 24-48 hours for the Google Analytics setup to take full effect. After I gave it a couple days, I went back and checked and now everything is set up correctly.
Setting up Google Analytics and Google Tag Manager was a worthwhile experiment, and I’m looking forward to analyzing the site data it collects.