On my e-commerce site I have products which may belong to multiple categories at the same time. Product URL contains categories, so depending on how customer came to the page, we are displaying according category path both in the URL and the breadcrumbs. Each product in addition has its own product URL without categories in it, and this URL is used in canonical meta tag on all duplicate pages.

Problem here is how my store is tracked in GA: bunch of duplicate urls for the same product are messing up the statistics, so I am thinking to explicitly replace "location" dimension in the tracking snippet with canonical URL value from meta tag (if it is present), and preserve all query string parameters (I am dealing with them separately on the view level). Need to mention, that I am tracking categories using custom content groupings, so, as for me it is OK to disregard category info in the "Page" dimension.

I just want to check with GA professionals if there is anything else against doing so?

Here is the code:

var canonicalUrl = Utils.getCanonicalUrl();
    location: canonicalUrl ? canonicalUrl + window.location.search : window.location
    // other custom dimensions
  • Help me understand: do you have something like example.com/category1/product1 and example.com/category2/product1 then a canonical url like example.com/product1? What about using a filter for condensing all product1 (that product1 string name needs to be unique) on a unique url (the canonical)? Then for categories you use custom dimensions? – lucgenti Jun 10 '15 at 22:47
  • Hi @lucgenti, yes you are correct. Well, it is valid solution too. Although, it seems to be more scary with filters, especially since there is unlimited nesting in categories. What do you think benefits are of this solution over what I proposed? Thank you! – vgrinko Jun 15 '15 at 15:14
  • I feel more confident with filters, because I can modify them directly from GA, without modifying single pages or templates. You can also store info scraping it from urls or page titles in custom variables. Also I like to have always a view without any kind of filters. – lucgenti Jun 15 '15 at 16:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.