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
-
Strange - Search Console page indexing "../Detected" as 404
Anyone seen this lately? All of a sudden Google Search Console is insisting in Page indexing that there is a 404 for a page that has never existed on our client's site: https://........com.au/Detected We've noticed this across a number of sites, precisely in this way with a capitalised "/Detected" To me it looks like something spammy is being submitted to the SERPs (somehow) and Google is trying to index that and then getting a 404. Naturally MOZ isn't picking it up, cause the page simply never existed - it's just happening in Search Console 2afc7e35-71e4-4e25-80a3-690bf10776a7.png It comes and it goes in the 404 alerts in Console and is really annoying. I reckon it started happening late 2022.
Reporting & Analytics | | DanielDL0 -
How important is Lighthouse page speed measurement?
Hi, Many experts cite the Lighthouse speed as an important factor for search ranking. It's confusing because several top sites have Lighthouse speed of 30-40, yet they rank well. Also, some sites that load quickly have a low Lighthouse speed score (when I test on mobile/desktop they load much quicker than stated by Lighthouse). When we look at other image rich sites (such as Airbnb, John Deere etc) the Lighthouse score can be 30-40. Our site https://www.equipmentradar.com/ loads quickly on Desktop and Mobile, but the Lighthouse score is similar to Airbnb and so forth. We have many photos similar to photo below, probably 30-40, many of which load async. Should we spend more time optimizing Lighthouse or is it ok? Are large images fine to load async? Thank you, Dave bg_05.jpg
Reporting & Analytics | | erdev0 -
Using Canonicals on category or link pages
Hey, If a site has category or tag pages showing in search results for a particular keyword - sometimes higher than the page you would like to rank - could using canonical redirects on categories and tags be a solution? Thanks
Reporting & Analytics | | wearehappymedia0 -
Hello, our domain authority dropped significantly overnight from 37 to 29\. We have been building good links from high DA pages and producing quality, regular content.
Hello, our domain authority dropped significantly overnight from 37 to 29. We have been building good links from high DA sites and producing regular, good quality content. Anyone able to offer any ideas why? Thanks
Reporting & Analytics | | ProMOZ1231 -
Is there a way to map your on-page SEO changes with the organic growth?
Hi Mozzers, I was just wondering if there's a way we can map our on-page SEO changes with the increase/decrease in organic traffic. For instance, I introduced brand pages' link the product page breadcrumbs and suddenly organic traffic for my brand pages increase from X to 2X in 1 couple of weeks. Now, this can be because of this breadcrumb change purely or because of some algorithm update or may be, bots started finding the content interesting and hence, started ranking them up (in case the brand pages were launched recently). So, you can't say which change should be mapped to what increase/decrease in organic traffic. Or, is there a way to map this?
Reporting & Analytics | | _nitman0 -
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 -
Google Webmaster says "0" pages indexed
Built my first Wordpress site. It launched a few months ago. Google has crawled 76 pages so far. But why are 0 indexed?
Reporting & Analytics | | cschwartzel0 -
Viewing 'overall' data for multiple Google Analytics accounts
Is there any way you can view data from all of your Google Analytics accounts? For example, if I wanted to view know how much mobile traffic all my sites had, could I do this? Rather than just looking at each site individually. Thanks
Reporting & Analytics | | intSchools0