eCommerce goaltracking still not working?

I read up on stuff a few days, added ~20 websites to the stats and am amazed how nice it is.

Although I do not like Google’s information gathering, we do have some nice sales reports there and they all seem to match quite well.

With piwik, not so much :wink:

I’ve been struggling with these ecommerce goal tracking links for a while now, tested on all kinds of variations, none seem to work. We use version 1.2.1

The code i use throughout all the pages is this:


<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.piwisite.tld/" : "http://www.piwisite.tld/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script><script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 2);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
piwikTracker.trackGoal(2, phpJsCashPiwi);
} catch( err ) {}
</script><noscript><p><img src="http://www.piwisite.tld/piwik.php?idsite=2" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tracking Code -->

Then on the actual salespage there’s a little javascript above this snippet, assigning a variable like this:


<script type="text/javascript">
     var phpJsCashPiwi = "46.45";
   </script>

However, when we use a static html page with this line hardcoded


piwikTracker.trackGoal(2, 10);

it does notshow either;-)

Do i need to look any further, or is this just not working (yet)?

Thanks,
Paul
1stpost;-)

trackGoal takes the goal ID. This is different from idSite. That said, multiples goals can be associated with a site. (many-to-one) A goal id cannot be shared between multiple sites.

as said vipsoft, your idgoal is probably 1 ?

otherwise, you can also try the new RC: 301 Moved Permanently

which fixes an issue when URLs are too long, we now put the most important parameters first

Ah, that explains things a bit.

So it is okay that many goals have id=1, as this is still matched with the current url? In short: 5 different URLs can all have goalid=1, and yet piwik knows that these are different websites/stores?

Kudos.

Goals are attributed to a website

so you define the website id in var piwikTracker = Piwik.getTracker(pkBaseURL + “piwik.php”, 2);

then the goal ID in piwikTracker.trackGoal(1);

the website id is stored in the piwikTracker object and the trackGoal request will send idsite and idgoal to piwik automatically

Thanks, I’m updating our Goals now and will watch the magic happen throughout the day (if we’re lucky;-)).

Good stuff. It seems to work now even though not every time. i’m a happy user.

Thanks for the replies!

In the next Piwik release, you can enable multiple conversions per visit.

We also moved the revenue parameter closer to the start of the tracking request, in case your web server truncates it prematurely.

In this case, the proper fix would be to reconfigure the web server (increasing the max request length, or request header size) or use setRequestMethod(‘POST’).

Hi,

Is there any logical explanation as to why certain sales are being recorded and others are not?

We’re talking about the exact same setup, thankyou pages and store script. Just different items or url (multiple stores on one central admin).

Thanks.

No, all conversions should be tracked properly. If not, there is some kind of error.

  • Check your server error logs
  • make sure all your goals are set with “Enable multiple conversions per goal”, and make sure you are using the latest RC3: 301 Moved Permanently

Hi,

I must be blind;-) I do not see any reference to “Enable multiple conversions per goal” in our backend.

Upgrading from 1.2.1 to the latest RC3 did not seem necessary to me, but if you say we’d best do that as well, we will later today.

TY

“Enable multiple conversions per goal” is only in the new RC

I’m actually uploading that release now. Taking a while though, been going at it for about 10 minutes ;-))

Edit:
I’ve been thinking about that feature though, why on earth would anybody want to track each goal only once?
Unless we’re not on the same page as to what our issue is, i really do not see the point of tracking it only once, haha.

Let me clarify that on our end each goal triggered is from another customer, not the same customer (unless he is a frequent visitor, in which case i do understand the new feature). Anyway, I’ll check in tomorrow to post results.

Update:
Looks like it is not working on our end still:
Websites 6 1 16.67% 0 € 16.67% 0 €

We’ll look into it some more.

of course, triggering a goal multiple times is PER visit, as is explained on the User interface…

I understand, seems obvious;-)

However my goals are registered, but not the price of the object.

I’ll put here exactly what I have and if we cannot solve it, we’ll check back some versions of piwik later:
Goal name: Sales
Where url contains: /checkout/onepage/success/
Checked: Allow Goal to be converted more than once per visit
Goal default revenue is 0

Other than that, the code from the first post is still used, except for the change in the goal id, which we set to 0, the same id as the Sale Goal.

I’m not an idiot, everything looks pretty tight, yet it’s not calculated right. Do we need to change the “where url contains” to something else? This is how we had set it up in Adwords.

Thanks.

If only the revenue is not tracked properly, it’s probably a bug in the call to trackGoal

can you try and pass the parameter as a string, eg. trackGoal(1, ‘11.50’)

On another website that is not Magento driven, we track an outgoing link which does work, as follows:


   <script type="text/javascript">
   //<![CDATA[
     // Create a var in the global scope.
     // Can be accessed by any Javascript that follows, anywhere in the page.
     var phpJsCashPiwi = "10";
   //]]>
   </script>

The only difference i can see (with my knowledge) is on the one (working) page, the var is hardcoded, within magento the var is filled with variable from php. However, when i look at the source code in both pages, the javascript code if filled in exactly the same.

Now that i think of it, the only difference might be the decimal point. Could it be there’s a bug in Piwik preventing numbers with decimals to be stored?

I’ll change

		
$piwik_saleamt = number_format($order_details->getGrandTotal(),2);

into


$piwik_saleamt = number_format($order_details->getGrandTotal(),0);

and see if this changes things.

Piwik works with the period (.) as the decimal point. It probably won’t work if the incoming data uses commas, e.g., “10,50”.

The other thing to check is if your web server has a limit on GET request lengths. This can cause the tracking request to be truncated. (In some versions of piwik.js, the revenue was the last parameter in the request.)

yeah, it wasn’t the decimal point.

Strange thing is it does work on one storefront, and not on another.

I recreated the goal and it did register one of my testsales. I’ll have to wait for more sales in that certain shop to see if it works there now all the time.

Will post back tomorrow.

Thanks.