Dumb SEO Questions

(Entry was posted by Arseniy Bolotsko on this post in the Dumb SEO Questions community on Facebook, 09/12/2013).

Question about Visitor segmentation with Google Analytic

I know that this is more of a Google Analytics question but I am sure someone in the group knows the answer. I need to segment member and non-member visits to a site. I know that custom even tracking in the way to go. I wanted to know how other people  implement this on their sites. So far i came up with this:
// _gaq.push(‘_setCustomVar’, 1, ‘visitor-type’, ‘member’, 2);
// >
Any ideas?
This question begins at 02:42:23 into the clip. Did this video clip play correctly? Watch this question on YouTube commencing at 02:42:23
Video would not load
I see YouTube error message
I see static
Video clip did not start at this question

YOUR ANSWERS

Selected answers from the Dumb SEO Questions Facebook & G+ community.

  • Ranu Jain: Hey Arseniy,

    These are the custom variables.  ;You can create these custom segments by modifying the Analytics tracking code. ;

    For more information read this: ;https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables
  • Justin Y: I just put this together and haven't tested it, but it should work or point you in the right direction.

    <?php
    $current_user = wp_get_current_user();
    if ( 0 == $current_user->ID ) {  ; ;
    // USER NOT LOGGED IN

    }  ;else  ;{  ; $user = 'Member' ; ?>

    <!-- ALL GOOD, THE USER IS LOGGED IN--> ;
    <script type="text/javascript">
     ; var _gaq = _gaq || [];
     ; _gaq.push(['_setAccount', 'UA-XXXXX-Y');
    <?php if (isset($userName)) : ?>
     ; _gaq.push(['_setCustomVar', 1, 'Member', <?php echo(json_encode($user)); ?>, 1);
    <?php endif; ?>
     ; _gaq.push(['_trackPageview');

     ; (function() {
     ;  ; var ga = document.createElement('script'); ga.type = 'text/javascript'; ga.async = true;
     ;  ; ga.src = ('https:' == document.location.protocol ? 'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
     ;  ; var s = document.getElementsByTagName('script')[0]; s.parentNode.insertBefore(ga, s);
     ; })();
    </script>

    <?php } ?>

View original question in the Dumb SEO Questions community on Facebook, 09/12/2013).

All Questions in this Hangout