i have a stupid problem in virtuemart 2 (joomla online-shop component) - my goals are not tracked reliable. ~40 percent orders are definitely not tracked as goals .
In my old piwik-version (must have been next to last) I tried JS tracking by page-title and part of uri on confirmation page. this page refers to paypal after 2 seconds. So i thought: "ok, perhaps this is the problem: 2 seconds is not enough to track reliable. I simply track goals one page before, onSubmit.
Today in the morning i updated piwik to Piwik 1.11.1 and put following code in the page:
jQuery(document).ready(function($) {
$('span#buyButton a').attr('href', '#');
$('span#buyButton a').click(function(event) {
event.preventDefault();
logGoal(8.7);
$('#checkoutForm').submit();
});
…and before :
<script type="text/javascript">
var _paq = _paq || [];
_paq.push(["setDocumentTitle", document.domain + "/" + document.title]);
_paq.push(["setCookieDomain", "*.myurl.de"]);
_paq.push(["trackPageView"]);
_paq.push(["enableLinkTracking"]);
(function() {
var u=(("https:" == document.location.protocol) ? "https" : "http") + "://www.myurl.de/piwik/";
_paq.push(["setTrackerUrl", u+"piwik.php"]);
_paq.push(["setSiteId", "1"]);
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>
<script type="text/javascript">
function logGoal(revenue){
try {
_paq.push(['trackGoal', 1, revenue]);
}
catch( err ) {}
}
</script>
<noscript><p><img src="https://www.myurl.de/piwik/piwik.php?idsite=1" style="border:0" alt="" /></p></noscript>
I changed the goal to manual triggering an then quick-tested: my visit and the goal was tracked correctly.
But now in the evening i looked again: again some orders were not tracked. I really ask myself why, the button has to be klicked for every order. nothing special in the order: the whole visit was tracked correctly.
I hope s.o. has a tip what i could test next.
Bye, Mojo
Update: I noticed, that in my last config Firefox-Orders are not tracked. I added a timeout for submit in onclick:
$('span#buyButton a').click(function(event) {
event.preventDefault();
logGoal(".$revenue.");
setTimeout(function(){ $('#checkoutForm').submit(); },1000);
});
My firefox test was successful, i am curious if everything works now.