1. This site uses cookies. By continuing to use this site, you are agreeing to our use of cookies. Learn More.

Editing the FB.init code to enable Social Interaction Tracking

Discussion in 'XenForo Development Discussions' started by Espen Espelund, Nov 16, 2011.

  1. Espen Espelund

    Espen Espelund Active Member

    I'm trying to add Google Analytics new Social Interaction Tracking and need to add some code after FB.init. What would be the best way to do this since the code isn't available from the template files?

    window.fbAsyncInit = function() {
      FB.init({appId: '<APPID>', status: true, cookie: true, xfbml: true});
      FB.Event.subscribe("edge.create",function(response) {
        if (response.indexOf("facebook.com") > 0) {
        } else {
    FB.Event.subscribe("edge.remove",function(response) {
      if (response.indexOf("facebook.com") > 0) {
      } else {
    FB.Event.subscribe("message.send", function(response) {
  2. digitalpoint

    digitalpoint Well-Known Member

    You don't need to do it during FB.init... you can do it after the fact just fine via your own JavaScript... FB.init needs to be called first, but it can be 10 minutes earlier (as an example) and binding the callbacks would still work.

    This means you can just have your own JavaScript file that is included after FB.init is called.

    We do the same thing for our Tweet button as well. You might find this post useful: http://xenforo.com/community/threads/better-google-analytics.21559/#post-272530
    Espen Espelund likes this.
  3. Espen Espelund

    Espen Espelund Active Member

    Thanks alot!

Share This Page