wpfb_add_to_asyncinit to add GA tracking code
-
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!
Viewing 1 replies (of 1 total)
Viewing 1 replies (of 1 total)
- The topic ‘wpfb_add_to_asyncinit to add GA tracking code’ is closed to new replies.