Apologies for an obvious question, but I’m a bit disoriented between Data Layers, Segments, Dimensions, Custom variables and Audience Manager.
What I’d like is to save the role of my visitor (member, admin, superadmin) during the session so that in Analytics I can check my custom events and see how many have been triggered by members/admins/superadmins respectively. I guess it’s a segment?
My question is, what is the piece of code I have to add to my app after log-in is successful so that any logged-in custom events would be accompanied by the user role?
Thanks in advance for anyone who spares eyes!
Hi,
it would be sufficient to set a session scoped custom dimension with a value like “member”, “admin” or whatever. This value (or the last one of you send multiple values during a session) will be available for all pageviews and other hits that occur during that session. You can report on the values using a custom report or secondary dimension in pretty much every standard report. Or build a segment for all sessions that came from users with a spefific role and apply it to your analysis.
In order to send a visitor role as dimension, you can set a value using the “Custom Dimension” tag type and trigger it before the regular page view. If you use manual tagging, set a value like this (assuming that the slot for this dimension is 1):
_paq.push(['setCustomDimension', 1, 'member']);
before sending an event or pageview.
When using the Tag Manager, the value will most likely come from a Data Layer variable and your site provides the value there on every page. If you do not have anything like that, you can trigger separate tags that define a role whenever a user navigates to a page that indicates which role to use, an element is visible… or whatever you can use to build a trigger.
Does that help to clear things up?
best,
Markus