4

I am building a social media site that is similar is structure to twitter and facebook.com where unauthenticated users who go to https://mysite.com will see a login + sign-up page, and authenticated users who go to https://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.

4

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.
]);
3

Use custom dimensions in Google Analytics.

  1. 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".

Screenshot borrowed from the blog post

  1. 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.