title: How can i track Facebook like on my website via Google Analytics?
body: <p>Going out of my mind on this one.</p>
  
  <p>I have Facebook like buttons on my ecommerce store. I have set them up using the XFBML and JAvascript SDK.. I am using the correct Meta OG properties.. everything work fine for facebook.</p>
  
  <p>Now this is where it goes wrong: I was trying to follow this guide: <a href="http://www.websharedesign.com/blog/how-do-i-track-that-little-facebook-like-button-in-google-analytics.html" rel="nofollow">http://www.websharedesign.com/blog/how-do-i-track-that-little-facebook-like-button-in-google-analytics.html</a> but it doesn't work for me as there a couple of differences. Firstly Im using the Async version of Google analytics... Secondly, my facebook like buttons get the URL automatically (In this article the user has manually put in the href...) So i changed the code to add in the gaq.push method instead;</p>
  
  <p>I have tried adding: </p>
  
  <pre><code>    FB.Event.subscribe('edge.create', function(href, widget) {
      _gaq.push(['_trackEvent', 'facebook', 'like', href]);
  }); 
  </code></pre>
  
  <p>into the main Async Facebook script, i have tried putting this on its own at the bottom of the page.. I have even tried adding this as an onclick= on the actual fb:like.</p>
  
  <p>The only time i got it to register anything was when i accidentally added that code in my main Google analytics  and then it generated a report for every page view as an event...</p>
  
  <p>Please help!!</p>
  
  <p>EDIT this is all my code: I have GA at the top of my page...</p>
  
  <pre><code>&lt;script type="text/javascript"&gt;
  
    var _gaq = _gaq || [];
    _gaq.push(['_setAccount', 'xxxxxxxxxxxxxxx']);
    _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);
    })();
  
  &lt;/script&gt;
  </code></pre>
  
  <p>Then below this FB is defined at the top of the body:</p>
  
  <pre><code>&lt;script&gt;
    window.fbAsyncInit = function() {
      FB.init({appId: 'xxxxxxxxxxxxxxxxx', status: true, cookie: true,
               xfbml: true});  
     FB.Event.subscribe('edge.create', function(href, widget) {
      alert('Facebook Like');
      _gaq.push(['_trackEvent', 'facebook', 'Facebook like', 'test']);
     });                 
    };
    (function() {
      var e = document.createElement('script'); e.async = true;
      e.src = document.location.protocol +
        '//connect.facebook.net/en_US/all.js';
      document.getElementById('fb-root').appendChild(e);
    }());
  &lt;/script&gt;
  </code></pre>
  
  <ul>
  <li>You see I have a put the gaq.push in the facebook code above - with an alert. Now this alert is fired when i click like, but the trackEvent is not sent to google? (Also, ideally where it says 'test' I would like the URL of the page...)</li>
  </ul>