Add a meta tag

Tealium Expert
Tealium Expert

Thought I could use the Content Modification extension to add a simple <meta ...> tag to the list of other such tags in <head..>. Realised that there is no id= I can use to hook it on to. I don't do xPath, could that be used here and what should I then enter as Identifier??

Thanks!

6 REPLIES 6

Add a meta tag

Moderator
Moderator

Hi @per_lundqvist - I took a look, and the Content Modification extension will always insert a <div> (with your 'content' inside), so you won't be able to use it to insert a <meta> tag directly into the head as you're hoping.

I know it's not what you were asking for (and I'm sure you know how to do this), but it's pretty easy to insert a <meta> tag with JS:

var n = document.createElement('meta');
n.name = "test-meta-insertion";
n.content="success";
var d = document.head;
d.appendChild(n);

 

Add a meta tag

Tealium Expert
Tealium Expert
OK, thanks!

Add a meta tag

Bronze Contributor
Bronze Contributor

Hello @calebjaquith,

I am not quite experienced with this but can you tell me how to add the code to get the meta description in the head. I tried the javascript extension with pre loader and with dom ready, but both don't add the meta tag to the head of the page.

Kind regards,

Erik

Add a meta tag

Moderator
Moderator

Hi @ErikDekker, if you put the snippet above into a JS extension with Pre Loader scope, a meta tag should be added the head, and that meta tag should also be picked up and added to the utag.data object on the page (works in my tests).

What are you seeing instead?

 

Add a meta tag

Bronze Contributor
Bronze Contributor

Hello @calebjaquith,

I looked in the sourcecode and didn't see the meta tag. When I look in the Tealium Tools I didn't see the extension loaded, but when I looked in the data > HTML metadata in the tealium Tools I saw the meta property. So it wasn't that obvious but I think it works now...

thnx for helping out,
Kind regards,
Erik

Add a meta tag

Moderator
Moderator

Hi @ErikDekker, excellent - glad it's working!

In case it's interesting for you: It makes sense that it wouldn't show in the source code, since we're injecting it via JS after the source has loaded.  But you should be able to see it in the 'Elements' tab of Developer Tools, since that view contains the info from the source as well as any dynamic changes that happen after page load.  Any DOM changes in TiQ can be checked like that.

Best
Caleb

Public