Mobile app version of vmapp.org
Login or Join
Ravi8258870

: Google Tag Manager: Extract value from a Custom JS Object I am implementing schema.org markup using JsonLD and Google tag manager. So I have a list of item that looks like this: data.itemListElement.push(

@Ravi8258870

Posted in: #GoogleTagManager #Javascript #JsonLd #SchemaOrg #Seo

I am implementing schema.org markup using JsonLD and Google tag manager.
So I have a list of item that looks like this:

data.itemListElement.push(
{
"@type": "ListItem",
"position": "2",
"item": {
"@type": "Product",
"image": "{{SCHEMA - Product Image}}",
"url": "{{SCHEMA - Product URL}}",
"name": "{{SCHEMA - Product Name}}",
"brand": "{{SCHEMA - Product Brand}}",
"category": "{{SCHEMA - Product Category}}",
"aggregateRating": {
"@type": "aggregateRating",
"ratingValue": "5",
"reviewCount": "700"
}
}
}
);


And I am getting the list of the different variables using a custom javascript variable that looks like that:

function(){

var urlList = [];

var urls = document.querySelectorAll("div.title-box-product-catalogue a.ng-binding");

if (urls) {
for(i = 0; i < urls.length; i++){
urlList.push({'url':urls[i].href});
}
}
return urlList;
}


It does return the list of url of my product list so this is working fine.

My problem is about using this array in my tag. I can not access the values.

I tried many things like:

"{{SCHEMA - Product URL}}.0.url",

"{{SCHEMA - Product URL.0.url}}",

"{{SCHEMA - Product URL}}[0].url",


But none seems to works, what I have in preview (and live) mode is always an Object list like this:



But I check theses "object" are filled with the right URLs,
Any idea about how I can access these ?

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Ravi8258870

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme