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.
Got a burning SEO question?
Subscribe to Moz Pro to gain full access to Q&A, answer questions, and ask your own.
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
-
Will adjusted bounce rate affect avg time on page?
I recently read Rob Beirne's piece on how and why to set up an adjusted bounce rate in Google Analytics (https://moz.com/blog/adjusted-bounce-rate). I am getting myself ready to talk to our site team about why we should set up an adjusted bounce rate and am anticipating some questions I'd like to be able to answer: 1. Will an adjusted bounce rate improve the accuracy of our avg time on page metrics? 2. Are we able to keep the unadjusted bounce rate in GA as well, so we can compare the two metrics if we ever need to? Does anyone know the answers to these questions? Any help would be much appreciated!
Reporting & Analytics | | seoisfun0 -
Which page speed tools do you trust?
We are at a loss. We have been following Google Pagespeed Insights which gives us horrible marks. Nothing we do seems to really make a difference. GTMetrix and Pingdom give us much better scores. We don't know what to do...
Reporting & Analytics | | HashtagHustler0 -
Help setting up FILTERS for External Payment pages?
Hi all, I own a webshop and believe my Google Analytics is not showing true data. At the moment when a user pays for their basket, they are redirected to an external secure payment page from my PSP, then after they have paid they are redirected back to my website. How is this visitor being counted? As the PSP-URL is a different site I assume this would be treated as an exit? Can I setup FILTERS to INCLUDE this URL so GA doesn't think its an external page or is there a better way? Thanks
Reporting & Analytics | | darrenbooy0 -
How to exclude traffic for a specific mobile device in Google Analytics view?
Hi, Need help on how to exclude traffic for a specific mobile device in Google Analytics view. I have been searching and the only information available is excluding IP address of internal traffic. Is there any way to exclude traffic through a mobile MAC address?
Reporting & Analytics | | Khadija_K0 -
No Google Analytics code on page BUT reporting is active
How could Google Analytics be reporting data if my pages don't have the GA code on them? Mike
Reporting & Analytics | | Mike_c0 -
How serious are the Duplicate page content and Tags error?
I have a travel booking website which reserves flights, cars, hotels, vacation packages and Cruises. I encounter a huge number of Duplicate Page Title and Content error. This is expected because of the nature of my website. Say if you look for flights between Washington DC and London Heathrow you will at least get 60 different options with same content and title tags. How can I go about reducing the harm if any of duplicate content and meta tags on my website? Knowing that invariably I will have multiple pages with same content and tags? Would appreciate your advice? S.H
Reporting & Analytics | | sherohass0 -
View entrance keyworsd for a subpage in google analytics
I have an element from ringcentral that is tracked by google analytics, yet for the life of me I cannot figure out to how to view the entrance keywords to that element. I can view the search metric and see which keywords and how many visits from each keyword onto the site in general, but how do I see which keywords were actually responsible for this 'click to call' code which has GA? I can see the total number of clicks into that code, but not which keywords led to it.
Reporting & Analytics | | ilyaelbert0 -
GA custom reports involving pages and goals - what are the metrics saying?
Hi, All! I would like to create a custom report that will enable me to see which of my pages are contributing to goal completion on my site (so I can then optimize the pages that are contributing the most, with maximal ROI for the optimization investment). If I make the dimension "page/page title" and the metric "goal X completions" - which would make sense - what exactly are the numbers that I am seeing telling me? Is it how many times a person started the goal funnel from that pages (meaning every goal would appear only once and there be no overlap)? That doesn't appear to be the case with the numbers, because the headline in the main "Goals" section tells me I have 30 goal completions for that goal, for example, but the headline in the custom report (which is adding up all the numbers) is, say, 100. Or does it mean the number of times that this page was ever in the navigation path of someone who ended up completing a goal? Then the same goal would be counted multiple times, for each page in the path. Additionally, I see this strange thing on some of my reports where the actual funnel pages appear as contributing towards goals, which I guess makes sense, but again the numbers don't match up. If the goal was to get to page B, and the funnel was A->B, and there were supposedly 30 goal completions, my custom report says that A gave 28 goal completions and B gave 25. Anyone know for sure - or through testing - what the case is with all these things? Any explanations will be much appreciated!
Reporting & Analytics | | debi_zyx0