I am trying to get custom dimension to be set for and reported in Google Analytics. I'm unable to see any passed values in any report.
In Google Analytics, for my property, in the settings, under 'Custom dimensions', I've added a custom dimension called 'userId' with index 1 (and scope 'User').
Based on this page, my tracking script in my site's pages header is this:
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'UA-XXXXXX', {
'custom_map': {
'dimension1': 'userId'
}
});
var dimensionValue = <?php print $userId; ?>;
gtag('event', 'userId_dimension', {'userId': dimensionValue});
($userId is an integer.)
In a report like 'Behaviour' -> 'Site content' -> 'Pages', I'm able to select a secondary dimension, including 'userId'. When selecting this secondary dimension, the resulting table has no rows. Even though, when inspecting my pages, the tracking code appears to pass the userId, and Google Analytics records visits that pass the userId.
What am I doing wrong?