WordPress.org

Ready to get started?Download WordPress

Forums

WP-FB-AutoConnect
[resolved] wpfb_add_to_asyncinit to add GA tracking code (2 posts)

  1. mtnporcupine
    Member
    Posted 6 months ago #

    Hello-

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

    Thanks!

    http://wordpress.org/plugins/wp-fb-autoconnect/

  2. justin_k
    Member
    Plugin Author

    Posted 6 months 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/

    Thanks,
    J~

Reply

You must log in to post.

About this Plugin

About this Topic