Mobile app version of vmapp.org
Login or Join
Gretchen104

: DataLayers, Wordpress and Analytics not showing any info I'm trying to use a JS function to retrieve data from categories, posts and etc, but I can't get any data. Here is the code I've been

@Gretchen104

Posted in: #CustomDimensions #GoogleAnalytics #GoogleTagManager

I'm trying to use a JS function to retrieve data from categories, posts and etc, but I can't get any data.

Here is the code I've been trying to use:

gtm_datalayers = function() {
var dataLayer = window.dataLayer || [];
var dl_title = document.getElementsByTagName('title')[0].innerHTML;
var metaPub = document.querySelector("meta[property='article:published_time']");

if(metaPub){
var dl_date = document.querySelector("meta[property='article:published_time']").getAttribute("content");
} else {
var dl_date = document.getElementsByClassName('published')[0].innerHTML;
}

var dl_author = document.querySelector("meta[name='author']").getAttribute("content");
var dl_category = document.querySelector("meta[property='article:section']").getAttribute("content");
//var dl_dates = dl_date != '' ? dl_dateEntry : dl_date;

dataLayer.push({
'Date': dl_date,
'Author': dl_author,
'Post': dl_title,
'Categories': dl_category,
});

console.log(dl_date, 'n', dl_author, 'n', dl_category, 'n', dl_title);

}


I placed correctly my custom dimensions in GTM , Analytics, but it seems that something is missing.

UPDATE

Here my configuration of my Custom Report:



Here is my Custom Dimension Config

10% popularity Vote Up Vote Down


Login to follow query

More posts by @Gretchen104

0 Comments

Sorted by latest first Latest Oldest Best

Back to top | Use Dark Theme