Dumb SEO Questions

(Entry was posted by Arseniy Bolotsko on this post in the Dumb SEO Questions community on Facebook, Thursday, September 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:

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


Selected answers from the Dumb SEO Questions G+ community.

  • Ranu Jain: Hey Arseniy,<br /><br />These are the custom variables.  ;You can create these custom segments by modifying the Analytics tracking code. ;<br /><br />For more information read this: ;
  • Justin Y: I just put this together and haven&#39;t tested it, but it should work or point you in the right direction.<br /><br />&lt;?php<br />$current_user = wp_get_current_user();<br />if ( 0 == $current_user-&gt;ID ) {  ; ;<br />// USER NOT LOGGED IN<br /><br />}  ;else  ;{  ; $user = &#39;Member&#39; ; ?&gt;<br /><br />&lt;!-- ALL GOOD, THE USER IS LOGGED IN--&gt; ;<br />&lt;script type=&quot;text/javascript&quot;&gt;<br /> ; var _gaq = _gaq || [];<br /> ; _gaq.push([&#39;_setAccount&#39;, &#39;UA-XXXXX-Y&#39;]);<br />&lt;?php if (isset($userName)) : ?&gt;<br /> ; _gaq.push([&#39;_setCustomVar&#39;, 1, &#39;Member&#39;, &lt;?php echo(json_encode($user)); ?&gt;, 1]);<br />&lt;?php endif; ?&gt;<br /> ; _gaq.push([&#39;_trackPageview&#39;]);<br /><br /> ; (function() {<br /> ;  ; var ga = document.createElement(&#39;script&#39;); ga.type = &#39;text/javascript&#39;; ga.async = true;<br /> ;  ; ga.src = (&#39;https:&#39; == document.location.protocol ? &#39;&#39; : &#39;&#39;) + &#39;.&#39;;<br /> ;  ; var s = document.getElementsByTagName(&#39;script&#39;)[0]; s.parentNode.insertBefore(ga, s);<br /> ; })();<br />&lt;/script&gt; <br /> <br />&lt;?php } ?&gt;

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

Reference Links

All Questions in this Hangout