riegersn
riegersn

Reputation: 2849

Not seeing page hits when filtering google analytics view by custom user scope dimension

Trying to set up different views using a filter on custom user scope dimension. Each user is part of different "organizations". Each organization has an ID. Now from what I read, anything under the User scope, sessions and hits, should all be sent automatically with a user custom dimension as long as I set properly. What I expected was to see the active users and their page views when viewing a filtered view in the scope of any specific organization id. However, what I'm actually seeing is active session users in realtime. the page they are on, but the actual page views seem to be getting filtered out.

My code looks like this...

gtag('config', 'UA-#########-' + gaCode, {
custom_map: {
    dimension2: 'defaultOrganization'
}

gtag('set', 'defaultOrganization', user.organizationId);

dimension2 is set up as user level, the view is filtering based on the specific organizationId. This is an SPA so I'm recording page hits like so...

gtag('config', 'UA-#########-' + gaCode, {
    page_path: $location.path()
});

As I said before i would expect any page views by that user to also send the custom dimension2 over, or at least show up when filtering in the view, but when I check under behavior > site content > all pages I see nothing.

When I view my original 'raw data' view with no filtering, I can clearly see the page hits.

What am I missing here?

Upvotes: 1

Views: 107

Answers (1)

bamdan
bamdan

Reputation: 856

From the documentation the custom dimension needs to be in a dictionary as per the mapping. It might not be parsed correctly on the ingestion by google analytics otherwise. Also it might be worth considering what a defaultOrganization event is. Might be worth considering using one of the default events google analytics default events

Try to send the dimension in the following form:

// Sends the custom dimension to Google Analytics.
gtag('event', 'any_event_name', {'dimension_name': dimension_value});

In this specific case it would be

// Sends the custom dimension 'defaultOrganization' to Google Analytics.
gtag('event', 'defaultOrganization', {'defaultOrganization': user.organizationId});

Custom dimensions and metrics with gtag.js Hope that works 👍

Upvotes: 1

Related Questions