jeudi 26 février 2015

ctrl + click disabled when using callback function


I have an image, which is also a link, of a product in my e-commerce webpage, I want to track using google analytics enhanced ecommerce tool whenever somebody clicks on the image. To obtain more accurate data in my google analytics reports, I stop the link from navigating to the next page, until the event is done sending data.


This is the html of the link:



<a href="/product_path" onclick="onProductClick();return !ga.loaded;">
<img src="/some_product.jpg" />
</a>


This is the javascript used:



<script>
function onProductClick() {

...

ga('send', 'event', 'UX', 'click', 'Featured' {
'hitCallback': function() {
document.location = '/product_path'
}
});
}
</script>


However, this causes that when I press ctrl + click on the image it doesn't open in a new tab as usual, it opens in the same one I am right now. And this is a functionality I would like it to keep working.


Anyone has any idea on how to restore that functionality?





Aucun commentaire:

Enregistrer un commentaire