Set up Google Analytics

Here are the most common questions being asked about how to set up Google Analytics.

How do I set up Google Analytics on my website?

There are a number of ways to set up Google Analytics on a website.

Global Site Tag (gtag.js)

This is the method that Google Analytics suggests as the default option after you have created a Google Analytics property.

The instructions are provided along with the code. Typically, if you want to use this option, you need to add this tracking code to the proper template, and Google Analytics will start tracking users and sessions on your website.

This is not difficult if you know how to do it or if have a webmaster who can add the code for you. However, adding this code provides only basic tracking on your website. You will be able to track pageviews, sessions, and users, but not events, nor does this code send your transactions or revenue to Google Analytics. You will not be able to create any event-based conversions. If you need extended setup or e-commerce tracking, you will need to add some more JavaScript snippets to your website.

See how to add events with JavaScript here.

See here for how to add enhanced e-commerce tracking with JavaScript.

This page shows how to adjust the default code for single-page applications.

If you need advanced tracking, you will need to add quite a lot of JavaScript code to your site, which may be not very simple.

Google Tag Manager

Google Tag Manager is another option that is suggested when you create your Google Analytics property. 

Note that this is the recommended option if you have much analytics and tracking tags. Some people think they only need Google Analytics, but it is important to consider the following:

  • Are you going to use AdWords?
  • Are you going to use Facebook?
  • Do you need any affiliate pixels installed?
  • Do other marketing tools that you are going to use have any codes that should be installed on your site?

If the answer to any of these questions is “yes,” you’re better off using Google Tag Manager over Global Site Tag. Google Tag Manager is a good tool to keep all your tracking and remarketing codes properly implemented and arranged. Moreover, with Google Tag Manager, it is possible to add event and conversion tracking without adding any extra JavaScript to your site, meaning that you won’t need to involve developers in order to add additional tracking tags.

There are still some cases in which it is not possible to implement some event or pixel solely with Google Tag Manager. In those cases, you may need to add a JavaScript code to push an event and/or variables to dataLayer. In other words, you will still need to add JavaScript to your site, but a big advantage of Google Tag Manager is that this event and/or variable will be available for any tracking pixel that is implemented with GTM. With GTM, you need to push the revenue of a transaction with JavaScript to dataLayer, and it will be available for Google Analytics, AdWords, Facebook, AdRoll, Twitter and any other tag. Without Google Tag Manager, you will need to add a separate JavaScript code to your site for each of these systems.


Most of the popular CMS like WordPress, Shopify, Magento, PrestaShop, Drupal, Joomla and so on offer some plugins for installing Google Analytics. Some of them also have plugins for installing Google Tag Manager.

If you have little or no experience with web development and do not have a webmaster who can help you, using plugins can be a good option for you. Still, if you plan to use more than just the Google Analytics tracking tag, seek out GTM plugins instead of GA.

Measurement Protocol

The Google Analytics Measurement Protocol allows you to send any kind of user interaction from almost any environment. This is not very popular because it is not very easy to implement as JavaScript or Google Tag Manager tracking. It is often used if you can send an event only from the backend or you want to send some offline events. More information about measurement protocol can be found here.

We hope you’ve found this article useful and that it helped you to properly set-up Google Analytics on your site. If you find Google Analytics a bit overwhelming, you may want to consider some of the alternatives.

Say Goodbye to Old Analytics Tools

Get a mind-blowing, personalized dashboard, automatically created.

Try it free