I would like to segment logged in and not-logged-in users using GA. The idea I have in mind is to create a Data Layer Variable (logged_in), and then ask my developers to push a value for that variable into the Data Layer on every page (either ‘yes’ or ‘no’). So the code would look something like:
var loggedIn = checkIfLoggedIn(); //returns ‘yes’ if logged in
dataLayer.push ({ ‘logged_in’ : loggedIn})
Now I assume there will be some server-side scripting involved using PHP and that this cannot be accomplished using pure Javascript. I am not aware of the details, but I guess my developers will be able to take care of it. As a not-so-technical marketer, all I need to tell them is to push so-and-so data into the dataLayer, right?
Next, I’ll create a GTM Google Analytics Custom Dimension tag that is fired on every Pageview event, and update a Custom Dimension on the logged-in status.
Will this approach work? Please let me know, thanks!