Tuesday 21 February 2012

Check which Network Your user are logged into- with Analytics

This is a simple method of finding out which user is logged into which social network while he is visitn your website:


There are 2 Major steps:

  1. Setup an empty Facebook app. Its free
  2. Install the Javascript code onto the page

Here are few sub steps:

Sub Steps:

  1. Login to Facebook.
  2. Go to the Facebook Developers page: https://developers.facebook.com/apps
  3. Press "Create New App" in the top right corner.
  4. For "App Display Name" enter anything you want; I used "TomTrack". Check the box to agree to the FB Policies and on to the next page.
  5. The next stage is pretty easy, just enter your domain in both the "App Domain" and "Website" sections

  1. Hit "Save Changes" .
  2. Grab the App ID from the top of the page and save it ready for the next section.

Install Javascript Code :you need to add this snippet of Javascript to the top of your page in the <head> section; this function will do the recording to analytics for us (this is for the asynchronous version of google analytics so if you are using the old version you need to remove it)


Next we add the following code to the bottom of the page before the </body> tag, ensuring you replce the appID in the Facebook code with that AppID you created above



Setting up Google Analytics

Custom segments are really easy to setup, and can give a keen insight into your analytics when used well. 
  1. Click "Advanced Segments" at the top of your analytics screen (once you're into the relevant profile), and hit "+ New Custom Segment" at the bottom right of the drop down.
  2. You'll be prompted to select a name for your segment and to select which facets to base it on. We'll be using the Custom Variable slots that the Javascript tracking code uses. Analytics allows 5 Custom Variable slots, and the code above uses 4 of these (1 = Google, 2 = Google+, 3 = Twitter, and 4=Facebook) [side note: I think you could cram all these into 1 slot possibly]. We'll make a segment for each; here is how I setup my Twitter segment:
  1. Hit "Save Segment" and you're done. Now repeat this for each of the other variables. Ensure you are selecting "Custom Variable (Value xx)" and not "Custom Variable (Key xx)".
  2. You're done and are ready to play with some data.


Viewing the data in analytics


Select those you are interested in and "All Visits" if you also wish to compare against all the traffic, and hit Apply.

No comments:

Post a Comment