DEV Community

lehidi
lehidi

Posted on

How to Quickly Install Google Analytics Global Site Tag in WordPress

What is Google Analytics?

Google Analytics is a free tool you can use with your Google account to track and generate reports on website traffic. It records information about website visitors, which pages they visited, for how long, from where in the world, how they reached your website in the first place, and a whole lot more besides. It even integrates with Google Ads to couple information about paid acquisition too.

1. Sign up for Google Analytics

Visit Google Analytics, and (if you aren’t already) sign in using your Google Account.
Hit the Start Measuring or Set up for free button and you’ll be shown a screen where you can enter your account’s details.
Then select Web when asked what kind of analytics you want to use.
Lastly, you’ll be asked for the website’s name and its URL, after which you can hit Create.

Get Your Global Site Tag

Having created your analytics account, you’ll be given a Tracking ID (which will be something like UA-1111111111), plus a snippet of code called the Global Site Tag which looks like this:

<!-- Global site tag (gtag.js) - Google Ads: CONVERSION_ID -->
  <script async src="https://www.googletagmanager.com/gtag/js?id=UA-1111111111"></script>
  <script>
    window.dataLayer = window.dataLayer || [];
    function gtag(){dataLayer.push(arguments);}
    gtag('js', new Date());

    gtag('config','UA-1111111111');
  </script>
Enter fullscreen mode Exit fullscreen mode

2. Use the MonsterInsights WordPress Plugin

The first method, and in my opinion the easiest and best method, is to use a plugin called MonsterInsights for WordPress.
In your WordPress admin, go to Plugins > Add New and search for monsterinsights. When you’ve found it, hit Install Now, and then Activate once that’s done.

Launch the MonsterInsights Setup Wizard
You’ll automatically be shown to a setup wizard where you can answer a bunch of questions to get things working, and you’ll be asked to connect MonsterInsights to your analytics account. You’ll be asked to log into your Google account, then authentication will be taken care of for you.

Reference Blog
How to Quickly Install Google Analytics Global Site Tag in WordPress

Top comments (0)