how to get the values from meta tag in adobe launch or adobe analytics

294 Views Asked by At

In meta tag, The "name" attribute as the variable name and the "content" attribute as the value of that variable.

<meta name="pageType" content="category" />
 <meta name="Country" content='india'/>

The variable will capture as: pageType = "category" when "pageType" match with condition then the value of "category" should go to into "evars" example :- evar5 = category and evar6 = india.

2

There are 2 best solutions below

0
On

You can try and do something like this to get the name and content of the meta tags and trigger your Adobe tag. You can add any "if" conditions on the name and content to only pass certain values. Additionally, you will need to map "name" and "content" to the corresponding eVars on the Adobe tag.

var temp_obj = {};
var metaElements = document.getElementsByTagName('meta');
for (var i = 0; i < metaElements.length; i++) {
    temp_obj.name = metaElements[i].name;
    temp_obj.content = metaElements[i].content;
    utag.link(temp_obj, null, [{UID of your Adobe Tag}])
}
0
On

Finally i got it.

var meta = document.getElementsByTagName("meta"); size = meta.length;

for(var i=0; i<size; i++) {
    if(meta[i].getAttribute("name")== "pwc_publication_date")
    {
        s.eVar6 = meta[i].getAttribute("content");
    }
    if(meta[i].getAttribute("name")== "pwc_title")
    {
        s.eVar5= meta[i].getAttribute("content");
    }
    if(meta[i].getAttribute("name")== "pwc_articletype")
    {
        s.eVar7= meta[i].getAttribute("content");       }
    if(meta[i].getAttribute("name")== "pwc_modified_date")
    {
        s.eVar8= meta[i].getAttribute("content");       }
    if(meta[i].getAttribute("name")== "pwc_tags")
    {
        s.eVar9= meta[i].getAttribute("content");       }   
    if(meta[i].getAttribute("name")== "pwc_headline_image")
    {
        s.eVar10= meta[i].getAttribute("content");      }   
}

if you change the meta tags order also, you can store values into a particular variables.

Thanks for Help....