How does one use Google Analytics to track third-party shopping carts? Print

Source: Internet
Author: User

By appending some code, Google Analytics can track data from shopping carts in your own domain or even other domains. If your store website is in a different subdomain or domain from your primary website, configure your webpage according to the following instructions.

If your website starts the purchase checkout process for other subdomains (for examplewww.mystore.comSendshoppingcart.mystore.com):

Add the following lines (in bold) to the tracking code on your shop website and shopping cart page:

<script type=quot;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("mystore.com");
pageTracker._setAllowLinker(true);
pageTracker._trackPageview();
</script>

If your website starts the purchase checkout process on other store websites (for example, if youwww.mystore.comSendwww.securecart.com):

  1. Add the following lines to the tracking code on your shop website and shopping cart page. This code must occur above the code in step 1.

    <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>

  2. Change the link from the main website to the secure website to use as follows:_link. Please note that your Google Analytics tracking code and_gat._getTrackerMust be placed in_linkThe top of the call. If your current link is as follows:
    <A href = "https://www.securecart.com /? Store = Parameters "> buy now </a>

    Change it:

    <A href = "https://www.securecart.com /? Store = Parameters "onclick =" pagetracker. _ Link (this. href); Return false; "> buy now </a>

Regardless of whether Javascript is enabled, the above Code can provide a link to the user. Note that the escape character should be a backslash when it appears in the link or link text.

Important:If your webpage contains a call to _ trackpageview (), _ Link (), _ tracktrans (), or _ linkbypost (), your Analytics (Analysis) tracking code should be placed above these calls in HTML code. In this case, the trace code can be placed anywhere between the start <body> flag and JavaScript call.

If you use a form to send information to the shopping cart, use:

<form name="post_form" method="post" onsubmit="pageTracker._linkByPost(this)">

 

Important:If your webpage contains a call to _ trackpageview (), _ Link (), _ tracktrans (), or _ linkbypost (), your Analytics (Analysis) tracking code should be placed above these calls in HTML code. In this case, the trace code can be placed anywhere between the start <body> flag and JavaScript call.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.