Goal tracking and revenue problem [SOLVED]

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>&nbsp;<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;

Does anyone have any ideas, or even consoling comments will do?!! Surely this is not intended operation, and I like to think I have a basic level of competancy with these things, I can’t see anything wrong (except the result of course)!

If I understand what you’re doing, then direct entry on page 2 should trigger the goal manually.

I’m not sure which timeout you lowered, but did you also clear your browser cookies? There is a constraint that limits one goal conversion per visit.

BTW have you tried the Funnel plugin? Plugin to provide funnel analysis report · Issue #5640 · matomo-org/matomo · GitHub

Thanks for your reply and suggestions.

Yes, direct entry on page2 should trigger it manually and it does trigger it, just not properly! It tracks the goal as a separate visit (with no page views) at the same exact time, and from the same IP etc as the other visit (which does register a page view, but no goal). See screenshot 2.

I lowered the timeout that controls registering of unique visits, I forget the exact name but its “the” common one thats changed when testing. (i.e. so that if I visit 2 minutes apart, they show up as separate unique visits). I have not cleared my cookies, but then this is a brand new visit (after the timeout), and the goal does get converted so thats not the problem. (In any case I can’t rely on real visitors clearing their cookies for things to work!).

I’ve just checked the database entries in the ‘piwik_log_visit’ table and it is definitely stored as duplicate visits (i.e. not just a GUI duplication issue as I’ve seen before). See screenshot 3 attached. The entries are identical except the goal converted flag and the entry and exit URLs.

This is one unique visit (one load of a page) that causes duplicate entries, one with a page view, the other with a goal conversion. The correct operation should be one entry that has both a page view and a goal conversion.

This makes no sense and I really think its a bug with Piwik rather than something I’m doing wrong. Very happy to be proven wrong though!

Kevin

I’ll try to duplicate the problem you’re seeing.

In the meantime… the timestamps on your visits show that less than two minutes elapsed between the page views. So it appears there’s a gap between what you’re trying to do vs what you intended to test.

Thanks for looking into it, I really appreciate it!

Sorry I just made the 2minute figure up on the spot because I couldn’t remember what I set it to. I’ve checked and I’ve got the timout (‘visit_standard_length’ in the config file) set to 60 seconds.

I’ve checked in the database, and the timestamp for testcase 1 is 2011-01-20 20:52:08 and the timestamp for testcase 2 is 2011-01-20 20:54:00 so the 60-second timeout is not the problem.

kevin, please try this with SVN trunk. We have fixed one issue that could be the one you are experiencing?

Thanks for your help - This problem has been fixed in Piwik 1.2