Reply
Highlighted
Frequent Visitor
Posts: 83
Registered: ‎09-22-2015
Accepted Solution

Add a meta tag

[ Edited ]

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!

Reply
0 Kudos
Tealium Employee
Posts: 20
Registered: ‎08-15-2016

Re: Add a meta tag

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);

 

Frequent Visitor
Posts: 83
Registered: ‎09-22-2015

Re: Add a meta tag

OK, thanks!
Reply
0 Kudos
Visitor
Posts: 3
Registered: ‎11-02-2016

Re: Add a meta tag

[ Edited ]

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

Reply
0 Kudos
Tealium Employee
Posts: 20
Registered: ‎08-15-2016

Re: Add a meta tag

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?

 

Visitor
Posts: 3
Registered: ‎11-02-2016

Re: Add a meta tag

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

Tealium Employee
Posts: 20
Registered: ‎08-15-2016

Re: Add a meta tag

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

Reply
0 Kudos