Search code examples
google-analyticsanalytics

Tracking external links with Google Analytics trackPageview() not working


I have set up external link tracking as Goals in Google Analytics according to the GA documentation.

Here is the page in question: http://playmoreatthey.org/ - the external links on the page are formatted such as

<a href="http://www.ymcagreaterprovidence.org/Default.aspx?alias=www.ymcagreaterprovidence.org/baysidebranch" onclick="javascript: pageTracker._trackPageview('/G1/bayside_family.com');" target="_blank">Bayside Family YMCA</a>

I set up the goal as a "head match" to the URL: /G1/bayside_family.com

I checked back four days later, and there are no results in the goals or pageviews for the phony "pagename" (/G1/bayside_family.com) specified in the JavaScript attached to each external link.


Solution

  • Looks like on your page you are using GA's async style code _gaq.push(...) but in your onclick you are using their old, "traditional" style code. You need to use

    onclick="_gaq.push(['_trackPageview','/G1/bayside_family.com']);"