Aynchronus e-commerce tracking

Hi,

it tried the following code to track product page view, but it’s not working:


HTML - TAGS

<script type="text/javascript">
<!--//--><![CDATA[//><!--
var _paq = _paq || [];_paq.push(["setEcommerceView", "12345", "Test", ""]);_paq.push(["trackPageView"]);
//--><!]]>
</script>

HTML - TAGS

<script type="text/javascript">
<!--//--><![CDATA[//><!--
var _paq = _paq || [];(function(){var u=(("https:" == document.location.protocol) ? "" : "piwik.org/");_paq.push(["setSiteId", "2"]);_paq.push(["setTrackerUrl", u+"piwik.php"]);_paq.push(["trackPageView"]);_paq.push(["enableLinkTracking"]);var d=document,g=d.createElement("script"),s=d.getElementsByTagName("script")[0];g.type="text/javascript";g.defer=true;g.async=true;g.src=u+"piwik.js";s.parentNode.insertBefore(g,s);})();
//--><!]]>
</script>

HTML - TAGS

when i use this code, it works:


<script type="text/javascript">
<!--//--><![CDATA[//><!--
var _paq = _paq || [];(function(){var u=(("https:" == document.location.protocol) ? "" : "piwik.org/");_paq.push(["setSiteId", "2"]);_paq.push(["setTrackerUrl", u+"piwik.php"]);_paq.push(["setEcommerceView", "12345", "Test", ""]);_paq.push(["trackPageView"]);_paq.push(["enableLinkTracking"]);var d=document,g=d.createElement("script"),s=d.getElementsByTagName("script")[0];g.type="text/javascript";g.defer=true;g.async=true;g.src=u+"piwik.js";s.parentNode.insertBefore(g,s);})();
//--><!]]>
</script>

But i’m unable to combine both in my current cms.

Where is the problem?

Using latest piwik version from svn.

Peter, I tested and see a problem: the first code must only contain the “setEcommerceView” call, not the trackPageView() call.

The problem is that, the first call stacks the setEcommerceView & then your extra trackPageView()… and when Piwik executes the functions, the setSiteId and setTrackerUrl haven’t yet been called so the request fails. If you just call setEcommerceView(), it will set the custom variables, then the trackPageView() in the standard Piwik call will record the pageview after the setSiteId and setTrackerUrl were call and it will work OK!

Hello,

I tried the same but also without success. I can see that piwik track everything correctly in the visitor log but without creating an ecommerce order. There is no error or warning.

I guess the code is similar to that above. I’m using piwik 1.9.2. I hope someone can give me a hint.


<script type="text/javascript">
<!--//--><![CDATA[//><!--
var _paq = _paq || [];_paq.push(["addEcommerceItem","12931","Test","No category",399,1.00]);_paq.push(["trackEcommerceOrder","310",402.9,399,64.33,3.9,false]);
//--><!]]>
</script>

<script type="text/javascript">
<!--//--><![CDATA[//><!--
var _paq = _paq || [];(function(){var u=(("https:" == document.location.protocol) ? "test" : "test");_paq.push(["setSiteId", "3"]);_paq.push(["setTrackerUrl", u+"piwik.php"]);_paq.push(["trackPageView"]);_paq.push(["enableLinkTracking"]);var d=document,g=d.createElement("script"),s=d.getElementsByTagName("script")[0];g.type="text/javascript";g.defer=true;g.async=true;g.src="test";s.parentNode.insertBefore(g,s);})();
//--><!]]>
</script>

Chris

I am also having the issue. Did any one found workaround for this?
My script looks same as above.

I am using piwik 1.9.2

Please, provide me with resolving info through PM. Ty.

You have to set the tracker URL and site is BEFORE you call trackEcommerce.