Hi all,
I’ve had a check through the forums and couldn’t find anyone posting about this issue. I found a few posts relating to what I want to do, but using the same code I can’t get it to work. Here is my problem:
In my test case, I have two pages (see code at the bottom).
Page 1: has the regular javascript tracking code
Page 2: has the regular javascript tracking code + “piwikTracker.trackGoal(9, 8.61);” added on the line before the trackPageView().
Goal 9 is a “Goal is manually triggered using the JavaScript API trackGoal()” goal.
Here is what happens (screenshots at the bottom):
Test case 1: I go to Page1 which contains a link to Page2. I click on the link and so go to Page2. This works fine, the visit shows up with two page views, and a goal conversion. See screenshot [1].
Test case 2: I go to Page2 direct using the URL. This does not work fine! The visit shows up with the page view, but no goal conversion and a duplicate visit shows up (same time, IP address etc) with no page view, but a goal conversion. See screenshot [2].
My timeout is set very low so yes, it does recognise each test case as a unique visit. I don’t know whether this is an issue with the code, with the GUI not showing it properly, or if the data is actually recorded in the database wrongly. I’ve tried multiple placements of the TrackGoal() line and they all seem to do the same thing.
Someone please help if you can! I’ve been trying to get this revenue tracking for ages. I eventually want to extend this to using a PHP call inside my Paypal script (incase people don’t come back to the confirmation page of my store) but if I can’t get this simple case to tie visitor-with-goal then I don’t know how it will tie up the javascript visitor with a PHP call to a goal conversion.
Thanks in advance to anyone who is able to chip in!
Page1 code:
<p> <a href="page2.html">Page2</a></p>
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.flashlight-heaven.co.uk/test/piwik/" : "http://www.flashlight-heaven.co.uk/test/piwik/");
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", 1);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script>
<noscript></noscript> <!-- End Piwik Tag -->
Page2 code:
<p> bloop</p>
<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.flashlight-heaven.co.uk/test/piwik/" : "http://www.flashlight-heaven.co.uk/test/piwik/");
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", 1);
piwikTracker.trackGoal(9, 8.61);
piwikTracker.trackPageView();
piwikTracker.enableLinkTracking();
} catch( err ) {}
</script>
<noscript></noscript> <!-- End Piwik Tag -->
Screenshots of [1] and [2] attached below;