0
votes

I need to tracking some User data for each post tag. For this, I'm using Google Analytics and Google Tag Manager. The dataLayer looks like:

{
"pagePostType":"post",
"pagePostType2":"single-post",
"pageCategory":["ha-kidd-knitting-supplies"],
"pageAttributes":["big-time-yarn","charles-voth","classic-shades","easy-knits","km066","knitted-cowl","textured-cowl","universal-yarn"],
"pagePostAuthor":"Charles Voth"
}

The pageAttributes key contains the tags.

How can I track all these tags without use dot notation? The posts could have 1, 2, 3, 4... or more tags, so I can't use dot notation.

2

2 Answers

1
votes

I mentioned here in this answer Tracking WP Post Tags using Google Analytics and dataLayer (GTM) that for the pageAttributes, you should assign that as the value for a Data Layer type variable. That way you can just loop through that variable and access each element of that array.

enter image description here

0
votes

You could get the whole pageAttributes array using dataLayer variable in GTM and then get individual tags by using array length.