0
votes

I have configured several content groupings in my Google analytics account. For grouping I use client JavaScript tracking code.

I have 5 groupings in Google Analytics account. All of them are invoked using tracking code. I use gtag.js. Important to note that each page on the website calls content groupings.

When I configure groupings using Rule definitions everything works fine. Only calling gtag.js for grouping causes problems.

Here is the code I use to call groupings:

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-37272891-3');

gtag('set', {'content_group1': 'smartphones_bybrand_metro'});
gtag('set', {'content_group2': 'samsung'});
gtag('set', {'content_group5': 'akademicheskaya'});

Expected result is to see my content groups ("smartphones_bybrand_metro", "samsung" and "akademicheskaya") in Google Analytics reports, e.g. in Landing Pages report. But I see "(not set)" groups for all visits. again, when I configure groupings using Rule definitions everything works fine. So clearly the problem is somewhere in JavaScript.

1

1 Answers

1
votes

Solved. Correct code is:

window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());

gtag('set', {'content_group1': 'smartphones_bybrand_metro', 
    'content_group2': 'samsung', 
    'content_group5': 'akademicheskaya'});

gtag('config', 'UA-37272891-3');