Support » Plugin: WP-FB-AutoConnect » wpfb_add_to_asyncinit to add GA tracking code

  • Resolved Nate Zander



    Thanks for the great plugin, we’ve been using it for a while.

    I am trying to hook in to FB’s edge events to send data to Google Analytics. On most sites I create the window.fbAsyncInit function.

    Since your plugin creates that function, I am trying to hook in to wpfb_add_to_asyncinit. However, the hook does not seem to fire. Does it only fire when someone actually logs in with the button? I need the code to be embdedded within the window.fbAsyncinit function.

    Here is my code:

    add_action('wpfb_add_to_asyncinit', 'cb_track_social');
    function cb_track_social(){
    	"console.log('FB loaded');
    	FB.Event.subscribe('edge.create', function(targetUrl) {
    	  console.log('track like please');
    	  ga('send', 'social', 'Facebook', 'like', targetUrl);
    	FB.Event.subscribe('edge.remove', function(targetUrl) {
    	  ga('send', 'social', 'Facebook', 'unlike', targetUrl);
    	FB.Event.subscribe('comment.create', function(targetUrl) {
    	  ga('send', 'social', 'Facebook', 'comment', targetUrl);


Viewing 1 replies (of 1 total)
  • Plugin Author justin_k


    You can see where that filter is referenced by searching for it in main.php (line 187 in the current version of the plugin). You can also view your page source to see what exactly is being output, & if it looks as you expect.

    In the future, please submit support requests on the support page:


Viewing 1 replies (of 1 total)
  • The topic ‘wpfb_add_to_asyncinit to add GA tracking code’ is closed to new replies.