Mobile app version of vmapp.org
Login or Join
Connie744

: Tracking logged in vs. non-logged in users in Google Analytics I am building a social media site that is similar is structure to twitter and facebook.com where unauthenticated users who go to

@Connie744

Posted in: #GoogleAnalytics #Javascript

I am building a social media site that is similar is structure to twitter and facebook.com where unauthenticated users who go to mysite.com will see a login + sign-up page, and authenticated users who go to mysite.com will see their timeline.

My question is, what is the best practice (using Google Analytics) for tracking these two different types of users who are viewing completely different content but are visiting the same URL.

I tried searching the Google Analytics docs but couldn't find what they suggested for this scenario. Perhaps I just don't know what keywords to search for.

10.02% popularity Vote Up Vote Down


Login to follow query

More posts by @Connie744

2 Comments

Sorted by latest first Latest Oldest Best

 

@Phylliss660

Use custom dimensions in Google Analytics.


First, navigate to the "admin" section of Google Analytics' web portal, click "Custom Definitions", then "Custom Dimensions" under the property you're selecting. Click "new custom dimension", give the dimension a name, and save it as type "hit".





Now add code similar to the following:

ga('create', 'UA-XXXXX-Y', 'auto');

ga('set', {
dimension1: __isUserLoggedIn__,
});

ga('send', 'pageview');


The bit marked as __isUserLoggedIn__ should be replaced with the relevant code. The number in dimension1 should match the number of the custom dimension created in the previous step.


For more details about this, see this great blog post on CSS Tricks.

10% popularity Vote Up Vote Down


 

@Si4351233

I finally found it in the Google Analytics Docs:


Use session-level custom variables to distinguish different visitor experiences across sessions.

For example, if your website offers users the ability to login, you can use a custom variable scoped to the session level for user login status. In that way, you can segment visits by those from logged in members versus anonymous visitors.


_gaq.push(['_setCustomVar',
1, // This custom var is set to slot #1 . Required parameter.
'User Type', // The name of the custom variable. Required parameter.
'Member', // Sets the value of "User Type" to "Member" or "Visitor" depending on status. Required parameter.
2 // Sets the scope to session-level. Optional parameter.
]);

10% popularity Vote Up Vote Down


Back to top | Use Dark Theme