How Do We Create the Canonical Domain?

Our canonical url is without www. We need to create page hostname, but make sure we always remove the www:
Page hostname canonical without www
Option 2.2: redirect the domain without www. To a domain with www. Via 301
Our canonical url is with www. We need to create page hostname without www (like before), and then insert the www in front using a constant variable:
Page hostname canonical with www
3. Enable the {{page path}} built-in variable
Enabled built-in variables
Note: although we have the {{page hostname}} built-in variable, for this exercise it’s preferable not to use it, as we’re not 100% sure how it will behave in relation to the www (e.G., in this instance, it’s not configurable, unlike when we create it as a gtm custom variable).
4. Create {{page url canonical}}

Link the Three Previous Variables to Form a Constant Variable

Hostname: we can force removal of the www Or not
Path: included from the slash /. Does not include the query, so it’s perfect. We use the built-in option for page path.
Page url canonical
Now that we have created {{page url canonical}}, we could even populate it into google analytics via custom dimensions. You can learn to do that in this google analytics custom dimensions guide.

How can we insert the canonical into a page using tag manager?
Let’s suppose we’ve already got a canonical url generated dynamically via gtm: {{page url canonical}}.

Now, we need to look at how to insert it into the page using a gtm tag. We should emphasize that this is not the “ideal” solution, as it’s always preferable to insert the tag into the <head> of the source code. But, we have confirming evidence from various sources that it does work if it’s inserted via gtm. And, as we all know, in most companies, the ideal doesn’t always coincide with the possible!

If we could insert content directly Loadrunner Protocol List into the <head> via gtm, it would be sufficient to use the following custom html tag: But, we know that this won’t work because the inserted content in html tags usually goes at the end of the </body>, meaning google won’t accept or read a <link rel=”Canonical”> tag there.

So then, how do we do it? We can use javascript code to generate the tag and insert it into the <head>, as described in this article, but in a form that has been adapted for the canonical tag:

And Then, We Can Set It to Fire on the “all Pages”

Job Function Email Database

trigger. Seems almost too easy, doesn’t it?

Rel canonical
How do we check whether our rel canonical is working?
Very simple: check whether the code is generated correctly on the page.

How do we do that?

By looking at the devtools console in EL Leads chrome, or by using a browser plugin like like firebug that returns the code generated on the page in the dom (document object model). We won’t find it in the source code (ctrl+u).

About lucía marín —

Hi, I’m lucía marín, a google tag manager & analytics specialist from granada (spain). Nice to meet you 🙂

I see analytics as an integrated discipline, focusing on the optimization of conversions (cro) and continued improvement of websites: ux, seo, content and architecture, etc.

Leave a Reply

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

Previous post Accountant learn how to plan for the income tax return
Next post What is data analysis and how to use it in accounting?