Quick and Easy Guide to Adding Google Analytics to WooCommerce

by

7-layers of Security for Your WordPress Site

Your website needs the most comprehensive security to protect it from the constant attacks it faces everyday.

Quick and Easy Guide to Adding Google Analytics to WooCommerce

You’re finally getting traffic to your site. Yay! Congratulations! But now you need to figure out how to keep them coming back for more. This is where Google Analytics for WooCommerce comes in. It’s the best tool to understand user behavior and track your traffic. This article is an easy-to-follow guide on creating a Google Analytics account and integrating it with your WooCommerce site. 

TLDR: You can integrate Google Analytics to WooCommerce site by using a plugin or adding a piece of code to your theme file. Both routes can be risky, so before you make any changes to your site, take a full site backup with BlogVault. Even if you want to try a few methods to integrate Google Analytics, you can quickly restore a backup, and start again. 

There are two parts to google analytics WooCommerce integration: creating an account and integrating it into your WooCommerce site. The whole process will take you just a few minutes, and we highly recommend backing up your site before you get started. 

Creating a Google Analytics account

The first step to WooCommerce google analytics integration is to create an account. If you’ve already got one, you can skip ahead. If not, sign up with Google Analytics using the steps in this section.

There are two types of accounts to choose from Universal Analytics and Google Analytics 4. UA will stop working in July 2023. So we recommend you create a GA4 account, especially since you are starting afresh. At present, you can also have both enabled. The following steps will help you create a property of either type. 

  1. Create the account: Go to Google Analytics and click Start Measuring. Fill in details like Account name and click Next.

  1. Fill in Property Settings: You’ll have to add your property name and select your location and time zone. Property usually denotes your site. 

Note: We recommend you use a GA4 property because it is the new and updated version. The user interface and the metrics that are being tracked differ between UA and GA4 a little bit. If you’d like to enable both, click Show Advanced Options and toggle on the UA settings. Fill in the website’s URL and select the checkbox beside Create both a Google Analytics 4 and a Universal Analytics property.

  1. Fill in Business Details: Add details about your business like its size and what features of Google Analytics you want to see. Click Create after you’re done and I Accept. In the pop-up message, select the types of email communications you’d like.

If you’re using a UA property, you’ll have to enable Ecommerce Settings. Click on the gear symbol at the bottom left of your dashboard. This will take you to your Admin settings. In the View section, click Ecommerce Settings. Toggle on Enable Ecommerce and Enable Enhanced Ecommerce Reporting. Click Save.  

You’ve now created a Google Analytics account and property and are ready to integrate it with your WooCommerce site. 

WooCommerce Google Analytics Integration (2 Ways)

There are two methods that you can use to set up google analytics for WooCommerce. First, you can use a plugin by copying and pasting the Tracking ID to your site. This ID is what Google uses to collect data from your site to show on the Analytics dashboard. In some places, you will see this being referred to as a tracking pixel. The second option is to manually add a piece of code to your header.php file. Let’s get started on integrating it with your site.

Add Google Analytics to WooCommerce using a plugin

The easier and less risky route to connect Google Analytics to WooCommerce is using a plugin. In this section, we have outlined the steps to integrate two popular analytics plugins.

MonsterInsights

A very popular plugin is Monster Insights – Google Analytics Dashboard for WordPress. The setup is very easy, and we like it because it also provides a dashboard on WordPress. You don’t have to manually add a tracking ID. Just install, activate, and connect to your Google Analytics account.  

  1. Install and activate the plugin: For the Plugins menu, look for, install and activate the MonsterInsights plugin.
  2. Setup: As soon as you activate the plugin, you’ll be taken to the settings page. There, you should see a button to Launch the Wizard! Go ahead and click on the button to get started.
  3. Follow onscreen instructions: Make sure to select WooCommerce on the first screen, and then move to connect to Google Analytics.
  4. View analytics: Once the setup is done, you’ll be taken back to wp-admin. On the sidebar, you’ll see Insights has appeared. Click to explore the dashboard.

And that’s all there is to it!

WooCommerce Google Analytics

You can also use the WooCommerce Google Analytics plugin. Here is how to do it.

  1. Download the plugin: Go to the WooCommerce Google Analytics site and download the free plugin file. Click Proceed to Checkout. You’ll have to sign in with your WordPress account – fill in details like your name and address on the next page. Click Pay when you’re done. In the invoice, click Download. 
  2. Install and Activate Plugin: Head over to your WordPress dashboard. Hover over Plugins on the left and click Add New. Click on Upload Plugin and Choose File. Pick the zip file and click Install Now. Once it’s installed successfully, click Activate
  3. Connect to Google Analytics: Go to the WooCommerce page, click the Integration tab, and fill in either your Measurement ID or the Tracking ID in the Google Analytics Tracking ID field. 

  1. Finding the tracking ID: If you’re not sure how to find the tracking ID, the steps to find it differ between a GA4 property and a UA property. This is how you go about it:
  • GA4: If you only have a GA4 property, you’ll have to create a Data Stream. Click the gear symbol at the bottom left of your Google dashboard. On the left, click Data Streams. Select Web and fill in the site’s URL and Click Stream. Once you’ve created the Data Stream, you’ll find the Measurement ID.

  • UA:If you’re looking for the tracking ID on a Universal Analytics property, you can find it in your Property Settings on your Google Analytic’s Admin settings (gear symbol on the bottom left of your dashboard).

  1. Enable appropriate analytics options: By default, there are a lot of settings that are enabled, depending on the type of site. We recommend you keep them checked because they’re the basic settings you’ll need to fully get the benefits of Google Analytics. But let’s dip our toes into what these settings mean:
  • Use Global Site Tag: It supports both UA and GA4 tracking IDs so tick it if you’re using both for the same site.
  • Enable Standard Tracking: This tracks basic details about your site’s traffic like – demographics. If WooCommerce Google Analytics plugin is the only Google Analytics plugin that you are using, make sure to enable this option.
  • Display Advertising Support: If you’re using Google Display Network, this option will help you track all related data
  • Use Enhanced Link Attribution: If you’d like to track the number of clicks for each button or link, this option needs to be selected
  • Anonymous IP address: Enable this option and keep your user’s details and IP addresses private. Note: This may be mandatory in some countries.
  • Track 404 error: Track a crashed site, broken links, and pages and be in a position to fix the issue before you lose too much traffic.
  • Purchase Transaction: Track revenue, purchases, shipping, tax refunds, etc with this tracking option. Make sure you’ve already enabled payment gateways into your WooCommerce site. If not, we’ve got articles that can discuss two popular payment gateways, Stripe and PayPal.
  • Add to Cart events: Enable this option to track when products are added to your cart and understand the user experience

  1. Fill in the domain: Scroll down and fill in your domain name in the Cross Domain Tracking field and click Save Changes.
  2. Set Goals and Funnels: Funnels help you optimise the user journey by “funnelling” the steps that a user takes to reach a goal. Goals measure how many customers perform an action or event. The process for both differs depending on the type of property you’ve integrated as seen below:
  1. Test your Google Analytics: You’re now fully setup but need to test it. Open your website on a new tab and go back to the Google Analytics dashboard. Go to the Real Time tab and see if it’s registering the users on your site. If yes, then you’re officially good to go.

Note: If you’d like two use two properties in parallel, you’ll have to integrate one property using a plugin and another using the manual method that we also discuss in this article.

Add Google Analytics to WooCommerce without a plugin

The manual method is fairly simple but it requires editing a core file. The tracking code needs to be inserted into every page of your site, and has to load earlier than the rest of the page content. This is why it is mostly inserted into the page header. Luckily, on most WordPress sites, the header is a separate php file in most themes. 

Since changes are being made to a core file, a small mishap could crash your site. So, backup your site first with BlogVault. It’s easy, automatic, and can restore a crashed site in minutes. Once you’ve backed it up, follow the steps below:

  1. Copy the Tracking code: Go to your Google Analytics account and depending on what type of property, use the steps below to find and copy your tracking code:
  • UA: On the bottom left, click the gear symbol to open Admin Settings. Next, click Tracking info and Tracking Code. You should now see the Tracking code.

  • GA4: Much like the Measurement ID, you have to go to the Data Streams page in your Admin settings and click the right data stream. Then, click the arrow besides Global Site Tag in the Add New on-page tag. The code should be revealed.

  1. Open the header.php file: Head to your WooCommerce site’s admin panel. Hover over Appearance on the left and click Theme File Editor. Then on the panel on the right, click header.php and that will open the code. In newer versions of WordPress, the theme file editor may be under another menu. Another way to access the header.php file is via FTP or File Manager on cPanel. 

  1. Add the Google Analytics code: Scroll down till you see the closing tag </head>. Add the code in a new line just above it. Click Update File after you’re done. 

  1. Set Goals and Funnels: Funnels optimise the steps that a user takes to reach a goal, like clicking Buy Now. Goals measure how many customers perform an action or event like clicking Purchase. The process for both differs depending on the type of property you’ve integrated as seen below:
  1. Test the integration: It might take 24 to 48 hours for the data to to be analysed but you can test it. Visit your site, and you should be able to see a user in the Real Time tab, which you can find on the left side of your Google Analytics dashboard. This collects real time data of visitors to your site. If you do see it, you’re all set.

Migrating from Universal Analytics to Google Analytics 4

Now that we’ve talked about how to connect Google Analytics to WooCommerce site, let’s talk about what to do if you already have a UA account. To migrate from UA to GA4, you essentially have to create a new property that is a GA4 property. 

Go to Admin Settings and click GA4 Setup Assistant in the Property Settings section. Click Get Started and Create Property

The new GA4 account will copy some of the basic settings but not the historical data. We recommend you use both in parallel.

Note: If you’re using the Google Tag Manager, you’ll have to install a new tag to start using the GA4 property. An error message will let you know if you’re not using gtag.js version of the tracking code, which is necessary for GA4 properties. 

There are some differences in user interface, the way data is analysed and some of the terms that are used. To understand it in more detail, we recommend checking out Google’s article on the differences. Additionally, if you’d like to duplicate some basic events for GA4, checkout this article on migrating from UA to GA4.

What to track using Google Analytics

  1. Location: Where are they buying from? You can use this information to market to them with targeted ads, for example.
  2. Bounce rate: This refers to how many people are leaving your site after visiting one page. A high bounce rate could mean issues with your website – maybe it’s too slow or maybe your content isn’t what they’re looking for. Either way, it’s an indicator that you have a problem to fix.  
  3. Product Stats: You can find out which products are doing the best and how you can leverage that interest. You can also find out what products could be doing better and how to market them. 
  4. Visitor Channels: A channel refers to how a visitor landed on your site – did they search for it using Google, did they type in your URL, did they find it through other links in a PDF. The ore information you know about your users and how they find you, the more information you have to improve marketing. 

Google Analytics and the EU

We love Google Analytics but should you be using it? If you’re living in the EU, we may have some news for you. In 2020, the Austrian Data Protection Authority (DPA) ruled that websites that use Google Analytics were breaking the General Data Protection Regulation (GDPR) laws. These laws determine what kind of data can or can’t be sent from the EU to the US. If you’re in the EU and using Google Analytics, we recommend you make the switch to an alternative analytics tool. Here’s an article by Termly that tells you more about the topic and gives you some alternatives. 

Final thoughts

You need Google Analytics to understand your users and track their behavior; both essential tools in building a site that your customer wants to visit. There are two ways to do WooCommerce google analytics integration: with and without a plugin. Either way, you’ll need a Google Analytics account with either a UA or GA4 property. You should also backup your site with BlogVault before you make any changes to your site. It’s the best backup plugin on the market and assures you easy backups with no downtime.  

FAQ

  1. Is GA4 replacing UA?

Yes. Google has announced that as of July 1st, 2023, Universal Analytics will no longer register any hits. GA4 will then become the default and we recommend you make the switch from UA to GA4 soon.

  1. Can Google Analytics track ecommerce traffic?

Yes. It can. It can track products you’ve sold, revenue, transaction data, etc. Google Analytics 4 does it automatically, but, if you’re using Universal Analytics, you have to specifically enable Ecommerce Tracking in the Admin Settings page. 

  1. Is Google Analytics compatible with WordPress?

Yes. It is. WordPress already has site trackers to analyze your traffic and Google Analytics has added features to complement it. All you need is to create a Google Analytics account and integrate it to your WordPress site using a plugin or adding the Google Analytics code to the header.php file. 

  1. How do I Connect Google Analytics to WordPress?

There are two methods to add a Google Analytics to WordPress:

  • With a plugin: Find the WooCommerce Google Analytics Integration plugin in the plugin directory, install and activate it. You’ll then have to paste your Tracking Code or Measurement ID in the appropriate field. 
  • Manually add Google Analytics: On the dashboard, go to the Appearance tab, click Theme File Editor. On the right, click header.php. Paste tracking code or measurement ID just before the closing </head> code. Click Update File
  1. How do I set up ecommerce tracking in Google Analytics?

On your Google Analytics dashboard, click the gear symbol in the bottom right. In the View section, click Ecommerce Settings. Toggle on Enable Ecommerce and Enable Enhanced Ecommerce Reporting. Click Save. Finally, Integrate Google Analytics with your WordPress site.

  1. How do I add Google Analytics to WordPress with a plugin?

The process requires installing and integrating a Google Analytics plugin with your Google Analytics account. Here are the steps to add Google Analytics with a plugin.

Category:

You may also like


ManageWP vs MainWP: A Head-To-Head Comparison
ManageWP vs MainWP: A Head-To-Head Comparison

When it comes to website maintenance, efficiency isn’t just an option; it’s an essential. Without diligent management, your website is exposed to numerous risks.  The user experience could degrade, you…

How can we help you?

If you’re worried that your website has been hacked, MalCare can help you quickly fix the issue and secure your site to prevent future hacks.

My site is hacked – Help me clean it

Clean your site with MalCare’s AntiVirus solution within minutes. It will remove all malware from your complete site. Guaranteed.

Secure my WordPress Site from hackers

MalCare’s 7-Layer Security Offers Complete Protection for Your Website. 300,000+ Websites Trust MalCare for Total Defence from Attacks.