lundi 16 février 2015

ReferenceError: "twttr is not defined" even while using twttr.ready()


Firebug console throws an error. It states that the code which I'm trying to use for tracking social events is used before //platform.twitter.com/widgets.js has finished loading asynchronously.



ReferenceError: twttr is not defined twttr.ready(function (twttr) {



However, I followed Twitter documentation ( http://ift.tt/1FjKDZz ), and wrapped it around twttr.ready(), in the same way one does with Facebook events.



<script type="text/javascript">
window.fbAsyncInit = function() {
FB.Event.subscribe('edge.create', function(targetUrl) {
ga('send', 'social', 'facebook', 'like', targetUrl);
});
FB.Event.subscribe('edge.remove', function(targetUrl) {
ga('send', 'social', 'facebook', 'unlike', targetUrl);
});
}
twttr.ready(function (twttr) {
twttr.events.bind('tweet', function(e){
if(!e) return;
ga('send', 'social', 'twitter', 'tweet', theURL);
})
});
</script>


Any hints?





Aucun commentaire:

Enregistrer un commentaire