Frequently Asked Question

Google Analytics
Last Updated 4 years ago

Google Analytics is a powerful tool for tracking traffic on your
site. Not just how many page views you get, but also where they come
from and how they flow through the site and a lot more.

This article will explain how to add Google Analytics to Cart32. A
few assumptions are made, such as that you already have a Google
Analytics account.
Please make sure that you have flagged it as an E-commerce site.
You will be given some code that looks like (If you have goals
enabled, there will be slight differences, such as an extra line):

var gaJsHost = (("https:" == document.location.protocol) ?
    "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost +
            type = 'text/javascript' % 3E % 3 C / script % 3E "));
            try {
                var pageTracker = _gat._getTracker("UA-XXXXXXX-X");
            } catch (err) {}

A few changes will need to be made to this. First thing you have to
do is add a line that will allow the tracking code to work across
domains. If your cart and site are on the same domain, you can skip

Add pageTracker._setDomainName("none"); below the var pageTracker =

var gaJsHost = (("https:" == document.location.protocol) ?
"https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost +

try {
var pageTracker = _gat._getTracker("UA-XXXXXXX-X");
} catch(err) {}

This code as is will go in all the pages on your website, near the
tag - this is towards the top of the page.

Each link that goes to the cart will need to be changed as well.

For the "add to cart" buttons and other forms, add


to each

The final result should be something like

Don't forget to use the address to your actual shopping cart and
your actual client code.

If you have just straight links to your cart as well, such as for
the View Cart feature, add

onclick="pageTracker._link(this.href); return false;"

to the end of the tag.

Next we will add the code to the template files.

The four main ones are:


NoItem.html is also needed, so the tracking is not broken if someone
empties their cart.

There are a few others that you can add the code to. It's mostly any
one that has a tag in it.

Add the following code near that closing body tag.

var gaJsHost = (("https:" == document.location.protocol) ?

"https://ssl." : "http://www.");

document.write(unescape("%3" + "Cscript src='" + gaJsHost +



try {

var pageTracker=_gat._getTracker("UA-XXXXXXX-X");




This code is slightly different from the normal code that Google
provides, but it is functionally the same. Cart32 looks for certain
string of characters due to some issues sometimes caused with
Frontpage. The slight modification is to alter the unescape() function
call to avoid that specific string.

Save your template files after adding this code.

The final step is to login to the cart, go to the Cart Settings ->
Google tab and check the box that says to use Google Analytics and
enter your UA number without the UA.

This will add e-commerce tracking to the GA code. Click save and you
are done

Please Wait!

Please wait... it will take a second!