Back to Basics: Data Collection II

Continuing with our Back to Basics series, we’ll now answer some frequently asked questions about data collection in Google Analytics.

1. Does it matter where I put the Google Analytics code?
The documentation states that the code should be placed before the `</body>` tag to minimize the impact on site load time. However, in modern browsers, this isn’t a problem because the code uses asynchronous downloading and doesn’t significantly affect overall performance. You can place the code in the header or footer, and it won’t have any impact, at least for the vast majority of users.

2. Is using Google Tag Manager mandatory for implementing Google Analytics?
More than mandatory, using Google Tag Manager is a best practice. As a recommendation, since implementing Google Tag Manager requires a certain level of experience, I suggest using the Google Analytics code directly for landing pages that will have a very short lifespan. For sites with a medium to long lifespan, implementing Google Tag Manager is recommended.

3. Can Google Analytics be implemented on a site that loads content dynamically using AJAX, AngularJS, or Backbone?

Yes, you only need to use virtual pages, which involves invoking the Google Analytics API using the `ga()` function. All Google Analytics tags can be used on this type of page or application.

4. How do you implement Google Analytics on a one-page site?
The traditional way! 🙂 All joking aside, for one-page sites you have two options:

Implement the code normally, as if it were any other page, and then use a UX Analytics tool, such as Hotjar or MouseStats, to understand user behavior in each section.

Implement virtual page tracking, activating it every time a section of the site enters the user’s viewport. The only issue with this option is that the metrics for time on page, bounce rate, and others were somewhat unusual, since they depend on the user’s scroll speed.

We’ll examine these cases in more detail in another blog post.

Leave a Reply

Your email address will not be published. Required fields are marked *

Get updates

Spam-free subscription, we guarantee. This is just a friendly ping when new content is out.