- TLC Home Home
- Discussions Discussions
- Documentation Documentation
- Knowledge Base Knowledge Base
- Education Education
- Blog Blog
- Support Desk Support Desk
We have the following i metadata:
<meta name="asset_topics" content="[{"sequence":"1","topic":{"topicId":"309","topicName":"Nutrition","topicTaxonomy":"Fitness and well-being/Food and nutrition/Nutrition"}}]" />
I want to set "topicTaxonomy" to a UDO variable. Suggestions? Thanks.
10-28-2015 01:44 PM - last edited on 10-30-2015 02:23 PM by kathleen_jo
Do you have jQuery loaded on your page @patrick_heavey?
10-29-2015 12:29 PM - edited 10-29-2015 12:50 PM
First, define the meta data element in TiQ so that Tealium is aware of it - make sure type is "Meta Data Elements":
Also add a new UDO topic_taxonomy data source.
In a Set Data Values extension scoped to All Tags you can set the topic_taxonomy UDO variable to the parsed value setting the variable to js code (note the code text is truncated in the image below):
JSON.parse(b['meta.asset_topics'])[0].topic.topicTaxonomy
Note that this will generate an error if the asset_topics meta tag does not exist. If there will be cases where it won't exist on the page, you can check for its existence:
(typeof b['meta.asset_topics'] != 'undefined') ? JSON.parse(utag.data['meta.asset_topics'])[0].topic.topicTaxonomy : ''
If your utag.js version is >= 4.38 you have the option of having this extension running before load rules if needed.
Unfortunately this didn't seem to work - nothing's being passed. :manfrustrated:
The issue is that you have non-encoded double quotes within other double quotes in the meta tag.
The meta tag content value is being read as "[{" becuase of the closing double quote.
To solve this you can use single quotes instead within the content value:
<meta name="asset_topics" content="[{sequence':'1','topic':{'topicId':'309','topicName':'Nutrition','topicTaxonomy':'Fitness and well-being/Food and nutrition/Nutrition'}}]" />
Note that this is not a Tealium issue. Search engines will stop at the second double quote as well.
Copyright All Rights Reserved © 2008-2023