Here’s How to Generate and Insert Rel Canonical with Google Tag Manager

We’ll do it using google tag manager and its variables.

Why send a canonical from each page to itself?
Javier lorente gave us a very good explanation/reminder at the 2015 seo salad event in zaragoza (spain). In short, there may be various factors that cause google to index unexpected variants of a url, and this is often beyond our control:

External pages that display our website but use another url (e.G., google’s own cache, other search engines and content aggregators, archive.Org, etc.). This way, google will know which one is the original page at all times.
Parameters that are irrelevant to seo/content such as certain filters and order sequences
By including this “standard” canonical in every url, we are making it easy for google to identify the original content.

How Do We Generate the Dynamic Value of the Canonical Url?

To generate the canonical url, dynamically we need to force it to always correspond to the “clean” (I.E., absolute, unique, and simplified) url of each page (taking into account the www, url query string parameters, anchors, etc.).

Remember that, in summary, the url variables that can be created in gtm (google tag manager) correspond to the following components:

Url variables in google tag manager
We want to create a unique url for each page, without queries or anchors. We need a “clean” url variable, and we can’t use the {{page url}} built-in variable, for two reasons:

Although fragment doesn’t form part of the List of Timeshare Owners url by default, query string params does
Potential problems with protocol and hostname, if different options are admitted (e.G., ssl and www)
Therefore, we need to combine protocol + host + path into a single variable.

Now, Let’s Take a Step-by-step Look at How to Create Our {{page Url Canonical}} Variable

Job Function Email Database
Note: we’re assuming that the entire website will always function under a single protocol. If that’s not the case, then we should substitute the {{page protocol}} variable for plain text in the final variable of step #4. (this will allow us to force it to always be http/https, without exception.)
2. Create {{page hostname canonical}}
We need a variable in which the hostname EL Leads is always unique, whether or not it’s entered into the browser with the  The hostname canonical must always be the same.

Leave a Reply

Your email address will not be published. Required fields are marked *

Previous post 6 Reasons for You to Participate in Conta Azul Con 2022
Next post 7 Lessons from the Professionalization of the Accounting Office