Google Analytics can track data from a shopping cart on your own website, or even on other websites, with the addition of some code. If your store site is on a different subdomain or domain than your main website, follow the instructions below to configure your website pages.
If your website initiates a purchase checkout process on a different subdomain (for example, if you send customers from www.onlinepaidlook.store.com
to onlinepaidlook.shop.com
:
Add the following line (in bold) to your tracking code on both your store site and your shopping cart pages:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._setDomainName("onlinepaidlook.com");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
</script>
If your website initiates a purchase checkout process on a separate store site (for example, if you send customers from
www.onlinepaidlook.store.com
to www.searchenginedetails.com
:
- Add the following lines to your tracking code on both your store site and your searchenginedetails pages. This code must occur above the code in Step 2.
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._setDomainName("none");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
</script> Change the links from the main site to the secure site to use
_link
as follows. Please note that your analytics tracking code and calls to_gat._getTracker
(shown in Step 1) must be placed on the page above the call to_link
. If your current links look like:<a href="https://www.searchenginedetails.com/?store=parameters"> Purchase Now </a>
change them to:
<a href=" https://www.searchenginedetails.com/?store=parameters" onclick="pageTracker._link(this.href); return false;">Purchase Now</a>
The code above provides links for users with or without JavaScript enabled. It’s important to note that apostrophes need to be escaped with a backslash where they appear in the link or link text.
Important: if your pages include a call to _trackPageview(), _link(), _trackTrans(), or _linkByPost(), your Analytics tracking code must be placed in your HTML code above any of these calls. In these cases the tracking code can be placed anywhere between the opening <body> tag and the JavaScript call.
If you send information to your shopping cart using forms, use:
<form name="post_form" method="post" onsubmit="pageTracker._linkByPost(this)">
Important: if your pages include a call to _trackPageview(), _link(), _trackTrans(), or _linkByPost(), your Analytics tracking code must be placed in your HTML code above any of these calls. In these cases the tracking code can be placed anywhere between the opening <body> tag and the JavaScript call.
How can I track return buyers with Google Analytics?
Have you ever wondered whether visitors to your site who purchase something end up returning to your site?
You can track how many return buyers you have by setting a user-defined variable on the receipt page using the pageTracker._setVar(“customer”); function. For example, if you set the user-defined variable to “customer”, you can then track how may customers return to the site after making a purchase.
How can I classify my visitors according to what pages they visited on my website?
Google Analytics allows you to define custom segments and analyze the behavior of each segment. For example, you might ask visitors to select their job category (such as SEM, SEO, Affiliate, SMO, Content, Analytics, etc) from a form. You could then analyze browsing and buying behavior based upon the selected job categories.
You can view conversion behavior for each of your custom segments from the Visitors Overview report. Click the User Defined link, then select the Goal Conversion tab.
To set a visitor segment, simply call the JavaScript _setVar function. For example, make the following call anywhere on the web page below your tracking code:
<script type=”text/javascript”>pageTracker._setVar(‘SEM/SEO’);</script>
Examples:
Assign visitors to a particular page to the “SEM/SEO” segment
In this example, anyone who visits the page will be assigned to the “SEM/SEO” segment.
<body onLoad=”javascript:pageTracker._setVar(‘SEM/SEO’);”>
Assign users to a segment when a link is clicked
<a href=”link.html” onClick=”pageTracker._setVar(‘SEM/SEO’);”>Click here</a>
Assign visitors to a segment based on their form selection
In this example, visitors are assigned to a segment according to their selection in a form.
<form onSubmit=”pageTracker._setVar(this.mymenu.options
[this.mymenu.selectedIndex].value);”>
<select name=mymenu>
<option value=”Affiliate/Content”>
Affiliate/Content</option>
<option value=”SEM/SEO”>SEM/SEO</option>
<option value=”Affiliate”>Affiliate</option>
<option value=”Content Marketing”>Content Marketing</option>
Add Comment