03 May Add Google Analytics Tracking Code to WordPress Site: A Step-by-Step Guide
Attracting lot of visitors to your new website never going to be useful if they are not doing what you want them to do. Understanding more about website visitors will help you to produce relevant content and can know what is stopping them to do complete the goal.
With the help of web analytics tools, you can very well understand people’s behavior on your site and their gender, device, location, the page they have seen, etc.
These data and reports will help you to take smarter and efficient decision in optimizing your ad spends and marketing activities. You can also understand what is stopping your customers from buying your product or opting in for your newsletter.
Some of the things that you can learn are:
Where are they coming from?
What do they on your site?
Who is coming to your site?
Are they doing what you want them to do?
What they are doing on your site?
Which campaign gave you more conversion?
Still many people are not using any of the web analytics tools because they don’t understand the importance or don’t know how to use it. The truth is, installing analytics tools like Google Analytics on your site is easy.
In this post, we will focus on creating Google Analytics account and setting up GA on a new WordPress site.
Why Google Analytics
Many analytics tools are available in the market. Such as,
However, Google Analytics has its advantages.
10 million websites use Google Analytics, and you too should use. Because it is,
- It is FREE!
Cookies are the small piece of information stored on a computer once a visitor visits your site. These cookies are used to store different information about the visitors, such as last visited date, login details, browsing history, and time of the visit, etc.
Creating Google Analytics Account
All you need is a Google account to create Google Analytics account. You can also use your business email id if you have bought it with Google.
First, go to Google.com then search “Google Analytics” and you click the relevant link or directly visit the following link https://analytics.google.com.
Now click on Sign Up option and log in to your Google account.
Before proceeding the next step, understanding the Google Analytics account structure is a must.
Google Analytics is organized into three levels: Account, Property, and View.
Account: Account name implies the company name. Within one Google Analytics account, multiple accounts can be created (up to 100).
Property: Each account(company) can have multiple web properties (up to 50) such as website, mobile app, kiosk, etc.
Say example; an e-Commerce company may have a website and mobile App. Both the website and mobile App should become as the different property under one account.
Views: Each property can have multiple views (up to 25). Views used to separate and filter the original data flowing into the data. ( You can create filter to exclude people visiting from particular range of IP address).
- Choose what you want to track. Either the website or mobile App (Default option is website).
- Enter the account name; you can use your company name for this.
- Each account/company can have multiple properties such as mobile App and website. Give name like yourcompany-website, yourcompany-App.
- Enter the website name of which you wanted to track.
- Choose a proper category it suits your site.
- Select the time zone you want the report to appear and click submit.
Once you complete the above steps, you will be provided with the Tracking ID.
It is unique to the property which you have created. Below that there will be a tracking code which you have to install on your site.
Depending on the platform you have used to build the website, it will change. We will discuss in deep how to add tracking code to the WordPress site.
Different Ways to Install Google Analytics Tracking Code To WordPress Websites
1. Theme Options
Most of the paid WordPress themes give the option to add Google Analytics tracking code inside the theme settings itself. But not all themes having this option.
Read the documentation of the theme you are using and use that option if you have one.
WordPress plugins help to customize website quickly. Many plugins are available in the WordPress free plugin directory for adding tracking code to the site.
Yoast Analytics plugin has 1+ million active installs with the rating 4 out of 5. This plugin has options for excluding logged in users, tracking external links, and tracking downloads such as PDF, DOC file.
You can also link to your GA account so that you can see your Analytics data in your WordPress dashboard itself.
Configuring this plugin is quite easy. After you have installed this plugin, navigate to “Analytics” option in the WordPress dashboard menu, then click “Settings”.
Two options provided to install the tracking code.
- Connect your GA account, it will automatically take the code and will insert on the website (you have to use this feature to use dashboard option).
- The second option is to enter your UA code (Tracking ID) manually.
You can also select the settings you want like ignoring users, if you are not clear, just leave default settings and save changes.
Using this plugin, you can add anything in header and footer of your site; such as a script to your site such Google Analytics Tracking, Facebook Pixel, etc.
Post installation of this plugin navigates to ‘Settings” in WordPress dashboard then Just copy and paste the tracking code. It will add that code to the footer of every page of your site.
Always insert the scripts in the footer (Adding any scripts to the header of the site may slow down website speed).
4. Add Code Directly
If you are familiar with editing code, you can use this option, but this one is not advisable.
Open the Functions.PHP (find it in the theme editor section) file in the theme section. Copy the GA tracking code and paste after <body > tag.
5. Google Tag Manager
Google tag manager helps you to organize tags on your site. As a beginner you can safely leave this step as of now and later, you can switch to this. You can easily Get Started with Google Tag Manager with the guide by Conversion XL.
When you want to add more tags, that might hurt your site’s speed and performance. But this tool will help you optimize site’s performance by reducing loading times drastically.
Site speed will affect your conversion. Amazon says, for every one-second delay in page loading it affects one percent conversion.
Ecommerce Tracking Through Google Analytics
The universal basic tracking code is limited to the data collection of the visitors. If you are running an eCommerce store, you need to add extra code and settings.
This additional code will help to know the product performance and the customer journey from visiting category page to the checkout page.
For that, you need to enable eCommerce tracking in Google analytics.
Navigate to Admin section of your GA dashboard, then select Ecommerce Settings.
By default related products tracking will be in disable mode, turn on that option. Proceed to next step.
In the next step, enable the enhanced eCommerce reporting option. Make sure you give labels to the customer navigation path in your online store which customer has to go through to complete order.
Usual customer path would be Category page, Product page, Cart page, Checkout section and thank you page.
Define the customer funnel on your site so that you can understand on which funneling stage has more leakage and fix it.
Once you completed the above step, you need to implement code to send data from your site to Google Analytics.
If you have used WordPress WooCommerce to build your online store, Enhanced Ecommerce Google Analytics for Woocommerce Store plugin, enables you to do the same.
Once install this plugin you will be getting options in the settings and you can configure it quickly.
Enter your UA code and website name, check Add enhanced E-commerce tracking code option.
Unselect “Add universal tracking code” as you have already installed that code, you need not add again.
How to Check Google Analytics is Collecting Data or Not?
A simple way to check whether Google Analytics is receiving or not is, open your site in an incognito window and go to your site.
Now, you can see 1 active user in Real-Time dashboard of Google Analytics which means GA is receiving your website data correctly.
If you have done this far, congratulate yourself. You have installed Google Analytics code in your website successfully.
But sometimes you might not have got the data even though you completed the above steps. Learn how to debugging the google analytics tracking code in the next section.
Debugging Google Analytics Tracking Code
If you are not receiving data, it might be because of the following reasons.
- The code might not have implemented correctly. You might have made some typo error, check with your Tracking ID and the tracking code added to your site.
- You can check whether you have added a code or not. Clear cache and try
- To check whether you have implemented Google Analytics correctly, install chrome extension and try. Google Analytics Debugger for Google Chrome.
Get Clean Data – Filter Internal Traffic
By default, Google Analytics will create one view name “All Web Site Data” which contains data about all the traffic to your site.
But when you want to understand about all visitors/customers you must exclude traffic from your company internal people like your developers, marketers, and admins.
For that, you need to create a filter to remove those visits.
Google Analytics(GA) gives the option to filter the visits based on attributes you specify, but this option will permanently delete data from you account, so it is advisable to have a backup of website visitors data.
Create a new view in GA dashboard by following steps and create filter in that view to a filter out traffic from your company.
Creating New View In Google Analytics
- Click Admin
- Select Views, then click new view
- Give name to new reporting view and select Time Zone
- Click Create view.
Next, select the new view you have created, and create a new filter using following steps.
Creating New Filter in Google Analytics
- Click on the Admin
- Then navigate to Filters (In view section)
- Click Add Filter to create a new filter.
- Give name of the filter ( make sure it is easy to identify)
- In the type of filters option – Choose Predefined
- Choose exclude option for removing traffic
- Select the “Traffic from the IP Address”. As we are going to eliminate traffic from you company IP address range.
- Select “Begins With” to cover the wide range of IP, that covers over all your company IP address.
- You can find your IP address by searching “What is my IP” in Google. If your company’s overall IP is not changing in first two part of IP address, then enter is. For example, if your company IP address always starts with 74.125 then enter that.
- Next click Save. Now you have successfully created a filter to exclude traffic from your company.
- But make sure that, you often check this IP address range make if the range differs from the previous one.
Enjoy analyzing. Struck with any of the above steps? Or have any questions about setup google analytics? Comment here or mail me.