Tracking data at goals

Hello,

First of all I would like to say thanks allot Piwik team for the amazing software.

My question is about the goals, I have set a couple of goals, 1 was easy it was just a page which has to be entered but others were a bit more difficult, there had to be a form submitted but in the data which shows up on the submit I added the following code which I hope works:

<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "----/piwik/" : "--/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(2);
} catch( err ) {}
</script>
<!-- End Piwik Tag -->

Anyway, my question is about the page(1) which is tracked as a goal. On the page before that page(2), data is entered which calculates a price on page1 (with cookies). When the price is calculated it would be very nice to view what price has been calculated in piwik.

Is this possible with piwik? and if yes is there some sort of guide to accomplish this or could anybody here help me further?

You can see the example page -google search “bereken dakgoot kosten”-*, the page is in dutch but it can help showing what I mean.

*keep getting “You have entered a link to a website that the administrator does not allow links to”

thanks in advance for any help.

Philippe

You’ll have to pass the amount from the previous page to the second page, e.g., using a query parameter or a cookie value. You can then pass that amount to Piwik when you record the goal, i.e., .trackGoal(idsite, revenue)

thanks for the help, I think i got it working already but am not sure… my outcome is:

<script type="text/javascript">
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackGoal(3, 1254,88);
} catch( err ) {}
</script>

will the double comma be a problem?


Hmm, I’ve been testing but can’t seem to get it to work, can’t seem to get it to work without the extra value either actually… on my visitor log i dont see the flag with data next to the page where it should show. anyone with an idea how this can be? I thougt maybe because I had the piwik code twice on my page one for the goal and one for tracking visitors

No, you can’t use the comma as a decimal separator.

In piwik 1.0, you can only track (at most) one goal per visit. (We have a ticket open to remove this limitation.)

I gave up on it earlier but got reminded how important this is so tried again… after a couple of hours I came up with the next code:


<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://http://www.dezinkspecialist.nl/piwik/" : "http://www.dezinkspecialist.nl/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
// ]]></script>
<script type="text/javascript">
var startnumber = "1132,12";
var replacednumber = startnumber.replace(/\,/g,"");
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackGoal(3, replacednumber );
} catch( err ) {}

</script>

<!-- End Piwik Tag -->

1132,12 is defined with “smarty” ( {$smarty.session.fbparams.bereken} )

on the bottom of my page i also have:


<!-- Piwik -->
<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://www.dezinkspecialist.nl/piwik/" : "http://www.dezinkspecialist.nl/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><p><img src="http://www.dezinkspecialist.nl/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
<!-- End Piwik Tag -->

you can view the page on


http://www.dezinkspecialist.nl/bereken-dakgoot-kosten/prijs-berekend.html
(there will be data if you click the top menu "indicatieprijs" then enter the fields and press berekenen)

Hope someone is willing to help.

edit:
I see it is working! but the only place i can see the calculated numbers is at the page goals, it does not show at live visitors.
When u used a comma in the price this did not work, now i have:


<script type="text/javascript">
var pkBaseURL = (("https:" == document.location.protocol) ? "https://http://www.dezinkspecialist.nl/piwik/" : "http://www.dezinkspecialist.nl/piwik/");
document.write(unescape("%3Cscript src='" + pkBaseURL + "piwik.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
var startnumber = "1350,36";
try {
var piwikTracker = Piwik.getTracker(pkBaseURL + "piwik.php", 1);
piwikTracker.trackGoal(3, startnumber );
} catch( err ) {}
</script>
and hoping the prices will show like €1350,36 instead of €135036,00

or should I change the comma in a dot?

I added your suggestion of displaying revenues in the ticket: Visitor Log list of ideas and improvements · Issue #1839 · matomo-org/matomo · GitHub

Thanks :slight_smile:

I think I did something wrong tho, the only notification of the achived goal in the visitor log is the yellow color.

I am still looking for a solution on how to display the goal prices and which goals have been achieved, is this possible at the moment with the recent updates of piwik?