Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Canonical URL in Analytics

Tags:

As far as I know, canonical URLs are only recognized by search engines - a way to ensure that when a search engine crawls your page, no matter which URL got it there, all of the "link juice" points to one canonical URL. So on a DNN site when example.com/, example.com/Default.aspx, example.com/tabid/36/Default.aspx, example.com/home/tabid/36/Default.aspx are all URLS for the homepage, a search engine can compress them all into one listing in it's index rather than diluting the PageRank across several URLs.

My question is whether canonical URLs are recognized by Google Analytics, or if there is any other trick to keep that same home page from showing up as 5 or 6 different pages (URLs) in Analytics.

like image 623
David Grenier Avatar asked Feb 01 '12 21:02

David Grenier


People also ask

What is meant by canonical URL?

A canonical URL is the URL of the best representative page from a group of duplicate pages, according to Google. For example, if you have two URLs for the same page (such as example.com? dress=1234 and example.com/dresses/1234 ), Google chooses one as canonical.

When would you use a canonical URL?

A canonical URL is used when all versions of the page should be accessible to visitors but only one of them should be indexed by search engines. A 301 redirect forwards both visitors and search engines from one URL to another URL. A redirected URL is not accessible for visitors or search engines.

What are canonical redirects?

Canonicals vs. While a redirect is a directive (it literally directs you to another page) a canonical tag is only a hint to search engines. That's a key difference that explains when to use one vs. the other. It's worth considering that whenever you use a canonical tag, a search engine may choose to ignore it.

How do I find my canonical URL?

A Canonical URL is an HTML tag in the <head> section of a web page. The best way to show the search engine which page URL has the original content.


1 Answers

Not recognized by default. But it's easy to setup GA to track the canonical urls when they are available.

instead of calling

_gaq.push(['_trackPageview']); 

You can use:

var canonical_link; try{   canonical_link = jQuery('link[rel=canonical]').attr('href').split(location.hostname)[1] || undefined; } catch(e){   canonical_link = undefined; } _gaq.push(['_trackPageview', canonical_link]); 
like image 145
Eduardo Avatar answered Oct 11 '22 23:10

Eduardo