Google Analytics multi-site tracking

under one account is a very common request from our clients.

You can find instructions on its website but they are quite general. A few years ago it was a most painful part of GA coding and most difficult to set up correctly.

Currently, after last years’ changes, it is quite easy to do.

You can track under one account:

  1. Subdomains—all visitors to both dogs.example.com and www.example.com, with data for both showing in the same report view (profile)
  2. Subdirectories—only visitors to the www.example.com/dogs subdirectory in a separate report as if it were a single site
  3. 3rd-party shopping carts—visitors to your online store and to your shopping cart hosted on another domain
  4. Top-level domains—all visitors to two domains that you own, such as www.example-petstore.com and www.my-example-blog.com, with data for both showing in the same report view (profile)
  5. IFramed Content—visitor and page view data for content in an iFrame of another domain.

Here I will concentrate on e-commerce  – point 3.

How to add Google Analytics cross-domain tracking to Magento and WordPress?

There are two steps. I will start with WordPress’ configuration.

  • you can use WordPress plugins like All-in-one Seo for such configuration and check “Track Multiple Domains” and “Enhanced eCommerce tracking”

google analytics multisite tracking

  • or add the script in header.php in your theme from your GA settings

Magento GA configuration

Make sure you Google API is enabled and configured in your Magento admin.
You can find it under Configure > Sales > Google API

  1. Next, you have to change GA.php file in your Magento shop via FTP.
  2. First copy the content of this file:  MAGENTOROOT/app/code/core/Mage/GoogleAnalytics/Block/Ga.php
  3. and create new file in code/local which will override the code/core one: MAGENTOROOT/app/code/local/Mage/GoogleAnalytics/Block/Ga.php
  4. In this file you need to find protected function _getPageTrackingCodeUniversal($accountId) and add following bold part:

protected function _getPageTrackingCodeUniversal($accountId)
{
return ”
ga(‘create’, ‘{$this->jsQuoteEscape($accountId)}’,’auto’,{‘allowLinker’: true});
” . $this->_getAnonymizationCode() . ”
ga(‘require’, ‘linker’);
ga(‘linker:autoLink’, [‘domain.com’,’domain2.com’]);
ga(‘send’, ‘pageview’);
“;
}

  1. Save the file and upload to MAGENTOROOT/app/code/local/Mage/GoogleAnalytics/Block/
  2. Next, you need to remove cache and check if your script looks following in the page source file.

Finally, your multisite tracking is done.

Other shopping carts

It is a very similar approach. You need to find out the GA files in your shop route.

Prestashop has an extension – Google Analytics API. You need to modify these files to enable a multisite tracking

Woocomerce – you can use All in One SEO plugin and enable  “Enhanced e-commerce”. I described it before in the WordPress part.

Google Analytics configuration for ecommerce tracking

It is really simple. You have a specific feature in Google Analytics Administration/account/view.

You need to choose the view and eCommerce settings to enable it.

google analytics ecommerce

You can define here your purchasing path in funnel steps. Next you need to submit and your are done.

Setting up Goals

In the end, it might be worth to setup conversion goals in Google Analytics to check if your website needs refinement, and eventually identify bottlenecks.

Please notice the url will have to be adjusted depending on your usage of Friendly Urls, especially if you use custom structures.

Goals can be defined in many ways. Google Analytics will suggest some most common and popular like the success pages for the order confirmation or the thank you page for the subscription confirmation.

You can add up to 20 goals per view.

Common goals:

Magento examples:

Goal Name: Successful Purchase
Select “Active”
Goal Type: URL Destination
Goal URL: /checkout/onepage/success/
Match Type: Head Match
Case Sensitive: do not check
Goal Value: 0
Use funnel: Select this (check it)
Click “+ Goal Funnel Step” about 6 times to have a total of 7 steps.
Step 1: URL: /checkout/cart/ Name: Cart
Step 2: URL: /checkout/onepage/ Name: Checkout Start
Step 3: URL: /checkout/onepage/billing/ Name: Billing Address
Step 4: URL: /checkout/onepage/shipping/ Name: Shipping Address
Step 5: URL: /checkout/onepage/shipping_method/ Name: Shipping Method
Step 6: URL: /checkout/onepage/payment/ Name: Payment Method
Step 7: URL: /checkout/onepage/review/ Name: Review/Confirm PRE-Payment

Prestashop’s examples:

  • /order (cart page)
  • /quick-order (one page checkout)
  • /order-confirmation (order placed)
  • /contact-us (contact us page)

Woocommerce examples:

  • checkout/order-received/
google analytics ecommerce
legalio multiplatform web analytics
conversion optimization

Conversion optimization

Conversion optimization CRO is the method of using analytics and user feedback to improve the performance
expert analysis