[resolved] wpfb_add_to_asyncinit to add GA tracking code (2 posts)

  1. mtnporcupine
    Posted 1 year ago #


    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);



  2. justin_k
    Plugin Author

    Posted 1 year ago #

    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: http://www.justin-klein.com/projects/wp-fb-autoconnect/


Topic Closed

This topic has been closed to new replies.

About this Plugin

  • WP-FB-AutoConnect
  • Frequently Asked Questions
  • Support Threads
  • Reviews

About this Topic