Soliloquy Blog

WordPress slider tips, Tutorials and Resources.

How to Add Google Analytics in WordPress

by [email protected] on January 15, 2018

Do you want to track your WordPress visitors with Google Analytics? Analytics are a big deal. Whether you’ve just launched your first website or your company has been popular for years, it’s extremely important to gather data from your visitors and customers. Once you know who your main user base is, where they’re coming from, and what they’re interested in, you can put this information to great use.

  • Get to know the demographics of your user base
  • Improve your marketing campaigns by learning who you should be targeting
  • See what links on your website get the most clicks

Google Analytics is just one of many analytics programs out there, but it’s regarded as one of the best. It’s easy to use, has a free version, can track a website without being installed onto the server, and is compatible with WordPress. If you want to start getting useful data on your primary demographics, here’s how to install Google Analytics in WordPress. We’ll also cover how to track image clicks on Soliloquy sliders!

Why Use Analytics?

If you’re just writing a personal blog (and aren’t particularly curious about who visits it), analytics may be unnecessary. However, if you’re writing in the hopes of growing traffic, or selling products on WordPress, analytics are absolutely necessary.

Google Analytics screen, showing visitor counts broken down by country

A program like Google Analytics can tell you many things about the people who visit your blog.

  • You can keep an eye on your traffic. Sudden increase in traffic? Maybe signing up for Twitter was a good idea after all, or your recent articles are just what people are looking for! A sharp decrease? Time to figure out what you’re doing wrong.
  • Where is that traffic coming from? Search engines? Social media? Advertisements? The answer can change your marketing or even your site design.
  • Where do people go when they visit your site? What are the hot pages? What’s being clicked on?
  • Who are the people who use your website (and who leaves immediately)? What countries are they from? What device are they using? You can even learn about their interests, age range, and gender! Business owners, pet lovers — who is visiting your website?

With this information, you have the power to drive sales and grow a community by knowing your audience and changing your marketing tactics.

Installing Google Analytics

There are a few different ways to get Google Analytics on your website — but regardless of which you choose, you’re going to need a Google Analytics account. If you have a Google account (for Gmail, Youtube, etc.) already, you can sign up with this. If not, go ahead and create one. You may need a mobile phone number to sign up.

Once you’re signed in to Google Analytics, begin filling out the form. Make sure you choose to track a website and not a mobile app.

Google Analytics account creation screen

Much of this is self-explanatory, but there are a few options that might confuse you.  Account Name can be whatever you want (the name of your company, the website you’re tracking), but make sure it’s descriptive, especially if you want to track multiple clusters of websites under different accounts. You can have up to 100 accounts.

Data sharing allows Google to use the data you gather to improve other services, such as Adwords. If you’re uncomfortable with this, just turn the settings off (your data may still be used to improve Google Analytics itself). However, turning off “technical support” data access could lead to tech support being unable to help you if you call with an issue. If you leave on “account specialists” access, you may get help and recommendations to improve your advertising from Google.

Once you’re done, click Get Tracking ID, and you’re finished signing up. You’re going to need this ID in a minute, so keep the page open.

Add Analytics With a Plugin

There are quite a few Google Analytics plugins for WordPress, and this is by far the easiest way to get the program onto your site. No messing with code, and statistics right on your dashboard. Here are a few of the best Google Analytics plugins.

These plugins mostly don’t need special installation or configuration steps. Download the plugin from the WordPress plugin repository, activate it on your dashboard, and find its setting page under “Plugins” to configure it.

You may need to authenticate your Google account. On the plugin’s settings page, there should be a button asking you to do so. Just sign in with the account you made before, and allow the plugin to access the data it needs to display your analytics statistics on the dashboard.

MonsterInsights banner, showing their cartoon monster icon inspecting several Google Analytics pages

Google Analytics for WordPress by MonsterInsights – This is the most popular Google Analytics plugin for WordPress, and for good reason. Real-time stats on your dashboard — and not just the basic statistics, but the ones that matter — and an e-commerce addon so you can get the data you need to make more money.

Google Analytics Dashboard banner, showing the Google Analytics view map

Google Analytics Dashboard for WP by ExactMetrics – If you’re more into blogging than e-commerce, you’ll love this one. It contains all the essential statistics you’ll need to start targeting the right people with your articles. There are real-time traffic stats, along with page and post reports so you can see how well your blog is doing, all on your admin dashboard.

Google Analytics+ banner, showing a stylized traffic graph

Google Analytics + by WPMU DEV is a premium plugin, part of a bundle that includes other plugins such as WP Smush, Forminator, and Autoblog. Along with tracking typical statistics like traffic, there are also e-commerce and marketing stats. The plugin is compatible with multisite, so you can use it on any WordPress install in your network.

Add Analytics Without a Plugin

Installing Google Analytics without a plugin is possible, but you’re missing out on an easy installation and some advanced features. In addition, your changes will be lost when you update WordPress or your theme (unless you use a child theme).

But if you still want to install analytics without a plugin, you can do so by following these steps. First, backup WordPress so you can revert to an older version if you break your theme or coding.

Return to Google Analytics and find your Tracking Code, the HTML located under “website tracking”. Copy it.

Google Analytics Tracking ID HTML

Go to your WordPress admin dashboard and head over to Appearance » Editor to modify your theme. You should see header.php on the right. Now just paste the code in below the <body> tag. Make sure to save your changes.

If you’d rather do it by FTP, find your theme’s folder in “/wp-content/themes/your-theme”. Manually find and edit header.php there. Just paste the code below <body>.

That’s all you need to do to enable tracking on your website!

Add Tracking to Soliloquy

Now that you have Analytics on your website, you just need to add tracking to your sliders. This will allow you to pinpoint which of your images are getting clicks, whether it’s to go to the link connected to it or even just to open it in a lightbox. Using Google Tag Manager linked with Google Analytics, you can cause triggers to “fire” when slider images are clicked. This is how you’ll keep track of your sliders.

To start, you’ll need to create a Google Tag Manager account. Follow the instructions given to add the code to your website, and also make sure to create a Google Analytics pageview tag. To finish setting up, click Variables » Configure and add Click ID and Click URL to the list.

From the Tag Manager homepage, click Add New Tag » Triggering. We’ll be setting this up so it triggers on any clicks made to a Soliloquy slider image. Click the plus sign in the top right corner to add a new trigger. Then click Choose a trigger type…  and select Just Links.

We need to ensure that this trigger only fires when users click on something with a Soliloquy image CSS class. Select Some Link Clicks. The drop-down menus should read Click Classes, contains, and in the last box type in soliloquy-image.

Once finished, save your work and return to the New Tag screen. Click Tag Configuration » Choose a tag type to begin setup… then Universal Analytics. Set the Track Type to Event.

Now fill out the Event Tracking Parameters. These can be whatever you like — it won’t affect how your tag collects data. Category groups together events you’d like to track, so name it “Soliloquy Slider” or something similar. Set Action to “Click”. Label is additional information about the event, but you can use codes like {{Click ID}} or {{Click URL}} to return these values. Leave the other settings on default.

Finally, click the Google Analytics Settings drop-down and New Variable. All you need to do is put in your Tracking Code from when you were setting up Analytics. With that, you’ve created a functional trigger that will track your slider image clicks and send the data back to Google Analytics!

Back on the homepage, click Submit to wrap up the process. You’ve now configured and published your new tag!

Helpful Analytics for WordPress

With Google Analytics, you’ll get a whole host of insights that will enable you to learn who your users are, target them with content they’ll love, and boost your viewership or sales. Sell the products, write the right articles, and know what your visitors are coming to your website for — all thanks to simple analytics!

We hope our article helped you install Google Analytics successfully. Want more WordPress tutorials? Visit our Facebook and Twitter to find helpful guides like this one, and let us know what you want to see in the comments!

SaveSave

Leave a Reply

We're glad you have chosen to leave a comment. Please keep in mind that all comments are moderated according to our privacy policy, and all links are nofollow. Do NOT use keywords in the name field. Let's have a personal and meaningful conversation.