Bug in Virtual Page view javascript
-
I am trying to learn the basics of tracking outbound links with this javascript code set up on
this url
http://queenofhats.com/links.php
I think I have a bug in my javascript that tracks clicks on an outbound link.
When A person clicks on the "Portland Maine" link, in theory it should create a virtual pageload of a page called "portland_maine".
I have clicked on the link, but when I filter on "portland" in the Top Content section of Google Analyitcs, there are is no record of the click.
So I think my javascript code has a bug.
Any comment on the javascript would be most welcome.
I just noticed that I have \ before /links.
Is the "" the source of the problem?
Thanks!!
-
Hi Guillaume:
I made the correction you suggested. See code below. I believe that because there is PHP on the page, that I Must keep the / before the ' marks. Correct?
I think that If I remove the / marks, that the web page will not render correctly in PHP becuase the ' mark is special character in php.
When I look in Google anlaytics under "portland" I see no page views.
So can you suggest what I need to change?
a href="http://www.portlandmaine.com" target="_blank" onclick= _gaq.push(['_trackPageview','/links/portland_maine']);">http://www.portlandmaine.com
Thanks!!
-
HI Guillaume:
Thanks very much for going to my web site and identifying the key point that I now have the new async version of GA on my site. So I have to use the new version of page tracking.
Good catch!
Merci
Dan
-
Hi Dan,
Yes, you're partially right, the "" is part of the problem, but there is also something else. I went and took a look at your website and you seem to be using the asynchronous version of Google Analytics code so the pageTracker won't work for you.
If you were still using the old version of Google Analytics, the code should be :
Now, with the new version of Google Analytics tracking code :
Best regards,
Guillaume Voyer.
Browse Questions
Explore more categories
-
Moz Tools
Chat with the community about the Moz tools.
-
SEO Tactics
Discuss the SEO process with fellow marketers
-
Community
Discuss industry events, jobs, and news!
-
Digital Marketing
Chat about tactics outside of SEO
-
Research & Trends
Dive into research and trends in the search industry.
-
Support
Connect on product support and feature requests.
Related Questions
-
Google Analytics - Tracking multiple thankyou pages?
Hi Guys, I want to track email opt-ins for multiple thank you pages. The setup is as follows: http://image.prntscr.com/image/57632e05a15f42fda0b8ffec2d176460.png I have not yet built the thank you pages, so i was wondering what the URL should be to make it easy to track them in GA? I'm thinking: domain.com/thankyou-page/page1 Then using regular expression in GA to track /thankyou-page/ Would this be a good way to go about it? Cheers. f6c7r0
Reporting & Analytics | | spyaccounts110 -
Is it possible to have a GA event and a GA virtual pageview fire off of the same click?
If we can only choose one, we'll likely go with the Event, but I'm hoping we'll be able to do both and gather more data about when certain pages (even if they are virtual) are viewed in the path to conversion.
Reporting & Analytics | | KNect3650 -
Moz Crawl shows over 100 times more pages than my site has?
The latest crawl stats are attached. My site has just over 300 pages? Wondering what I have done wrong? RRv3fR0
Reporting & Analytics | | Billboard20120 -
Google Analytics Page Metrics and Redirects
Hi All- Context: A site has been redesigned. Pages were renamed in the process. Problem: It's very hard to compare before and after metrics because the page URLs are not the same. Question: Anyone know how to do this in Google Analytics? I'm hoping there's some simple trick I just don't know about. D
Reporting & Analytics | | DonnaDuncan0 -
Conversion Rate Higher Than Landing Page Visits?
Interesting to see in Google Analytics that the conversion rate is higher than landing page visits - could it be attributed to a visitor clicking the CTA button multiple times? Or perhaps there is duplicate GA code on the conversion page since we utilize both Google Analytics and HubSpot. (see attached funnel screenshot) Screen-Shot-2014-09-26-at-10.49.09-AM.png
Reporting & Analytics | | W210 -
Google Analytics - Sessions vs Views?
In Google Analytics under Audience Overview I want to visit total visits during any given period of time but instead it shows me sessions. Am I missing something? How do I switch from sessions to page visits?
Reporting & Analytics | | gohawks77902 -
Organic Traffic From...Mountain View, CA?
I've noticed something a little odd in my organic search traffic lately. Looking at several websites that target the Minneapolis area, I'm seeing some organic searches come in (typically using head keywords - no geo-modifier) from Mountain View, CA. There's no way we are truly ranking well on these terms in California, so it certainly feels like Google sniffing around. I was worried that perhaps they were checking into penalizing us or something, but we've actually seen upticks in search traffic lately. This traffic is not showing up in Google Analytics, just Adobe SiteCatalyst. In the past, spikes from random locations were probably some sort of crawler, like the preview bot, but these are coming in as searches with (for now) keyword data. Has anyone else seen anything like this?
Reporting & Analytics | | SarahLK0 -
When javascript is disabled, does a visit register goal completion in Google Analytics?
I'm looking for reasons why Google Analytics goal completions would appear to be fewer than the actual known number of online sales for a company, and I'm wondering if disabled javascript is likely to be the primary cause of a discrepancy. Thanks for any insight you have.
Reporting & Analytics | | williammarlow0