Forum Moderators: DixonJones
I have a website that acts as a specialist product directory with external links to manufacturers websites that open in a new window.
In order to track external link clicks with Google Analytics I have recently changed the external links from the actual external url (e.g. www.anotherwebsite.com) to the following format: www.mywebsite.com/external/anotherwebsite.php. I then use an intermediate webpage containing the google analytics tracking code and a meta refresh to redirect the 'external' link on to the actual external url. The placement of the tracking code on the redirect page assists in tracking visitors who right click on an external link and choose to open link in new tab/window (as my previous GA code did not register any external link clicks initiated with a right click).
I have found that the above method is not ideal as:
1. The tracking code on the redirect page potentially records multiple page visits if the user tries to use the 'back' button on the newly opened manufacturer website(this has happended - 20 'visits' on a page from a single visitor!)
2. I think the meta refresh scrubs any referral data so that my website is not shown as the referrer when a user visits a manufacturers website from one of my external links.
I have looked into using a php redirect with (location: 'external url') in the header, but I understand that any Google Analytics tracking code placed on this redirect page would not be activated(?). I have even tried using a double redirect, (i.e. stage 1 = google analytics code + meta refresh to stage 2 = php redirect to external website) but I think this doesn't show referrer info (due to meta refresh?)
Can anybody suggest the best way to accomplish all of the following (whilst avoiding problems outlined above):
1. Collect accurate Google Analytics data for all external link clicks (including links opened using right click)
2. Avoid a 'back' link loop affecting Google Analytics page visist stats for external links opened in a new window
3. Keep the originating web page (i.e. my website) as the referrer
Thanks