Canonical Tags
Can we use Adobe Dynamic Tag Manager to add canonical tags to specific pages on Adobe Experience Manager (AEM)?
If yes, then can you please let me know how. If not then, is there any other way?
Regards
Can we use Adobe Dynamic Tag Manager to add canonical tags to specific pages on Adobe Experience Manager (AEM)?
If yes, then can you please let me know how. If not then, is there any other way?
Regards
It appears that you have two page load rules (in DTM staging) that are trying to do something with the canonical tag.
MEE Canonical - Contact Us
-and-
MEE home Canonical Tag
Let's focus on the "Contact Us" rule.
-It looks like you modified the conditions, changing the match against the "Hostname" data element (This looks like a good change).
-It also looks like you added a Path condition to the rule. I can tell this because of the addition of scope:{URI:{include:[/\contact/i]}
There are a couple tricky things about "path" conditions in DTM.
1) The evaluation is not against document.location.pathname as you might expect. It is against _satellite.URI() which includes both document.location.pathname and document.location.search.
2) If a path condition is not met, there is no indication in the console of the fact.
In your case, let's test your path condition in the console:
Navigate to Middle East Electricity | Contact
Open the Dev console.
> _satellite.URI() ---- returns "/en/contact.html"
> _satellite.URI().match(/\contact/i) ----- returns null (your path condition is not met)
> _satellite.URI().match(/\/contact/i) ----- returns an array (THIS WORKS!)
^^^ You are missing the forward slash in your Path condition.
(Or could just remove the backslash as in _satellite.URI().match(/contact/i) )
The ultimate way to know if your rule is working is to check for the expected outcome.
In this case, the expected outcome is the insertion of the HTML element,
<link rel="canonical" href="https://www.middleeastelectricity.com/en/contact.html" />
To do this, you can run this in the console: document.querySelectorAll('link[rel="Canonical"]')
When everything is hunky dory, you will see a NodeList array with one item.
============================================================
I hope that this gets you going. I have a couple other things to say.
1) I don't relly like Path conditions in DTM because they don't behave like one might expect.
2) In place of path conditions I like to create a data element for document.location.pathname and use data element comparisons in conditions.
3) The rule, "MEE home Canonical Tag", is set to run at pageBottom. This rule also has problems with conditions, but if you get past those problems, you will find that the tag is not inserted in the HEAD of the document. This rule should fire at page top.
Enter your E-mail address. We'll send you an e-mail with instructions to reset your password.