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 magento.stackexchange.com, 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 community@magento.com.

Magento Forum

Using google analytics to track outbound links
 
platinumtackle
Member
 
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 window.open() to open the url in a new tab or window.  However, if I add the pagetracker._trackPageview() call before the window.open 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/";
                
$url=$_product->getData('buyitnowurl');
                
$trackUrl=$trackDir.$url;?>  
             
        
<button class="form-button" onclick="[removed]pageTracker._trackPageview('<?php echo $trackUrl ?>');window.open('<?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