Posting in the Magento forums has been disabled pending the implementation of a new and improved forum solution which should better serve the community.

For new questions please post at, the community-run support site for the Magento community. We will be providing updates on the new forum solution soon. For questions or concerns please email

Magento Forum

Using google analytics to track outbound links
Total Posts:  40
Joined:  2008-09-30

I have added another button option to my products called buy it now.  This button is for products that I am not selling, but might interest a customer as it is associated with something I am selling.  I am using a button like the Add to Cart button to make them identical except for the text.  The problem I am having is that I am using the onClick attribute for the button to call javascript to open the url in a new tab or window.  However, if I add the pagetracker._trackPageview() call before the call the new tab or window does not open.  Is there another way I can use google analytics to track my outbound traffic with a button or do I have to change over to a link.

<?php  $trackDir="/outbound/";
<button class="form-button" onclick="[removed]pageTracker._trackPageview('<?php echo $trackUrl ?>');'<?php echo $url ?>','<?php echo $this->htmlEscape($_product->getName()) ?>);'">
span><?php echo $this->__('Buy It Now'?></span></button>
Magento Community Magento Community
Magento Community
Magento Community
Magento Community
Magento Community
Back to top