Callback function after a successfull tweet

webintent

#1

Hi,

I have used your developer’s code as in the following:
But I am unable to capture event after posted the message or tweet, rather the event is fired at the time of popup window opens.

<a class="btn twitter"
                       href="https://twitter.com/intent/tweet?text=test msg">Share on Twitter</a>

window.twttr = (function(d, s, id) {
  var js, fjs = d.getElementsByTagName(s)[0],
    t = window.twttr || {};
  if (d.getElementById(id)) return;
  js = d.createElement(s);
  js.id = id;
  js.src = "https://platform.twitter.com/widgets.js";
  fjs.parentNode.insertBefore(js, fjs);
 
  t._e = [];
  t.ready = function(f) {
    t._e.push(f);
  };
 
  return t;
}(document, "script", "twitter-wjs"));
 
// Define our custom event handlers
function clickEventToAnalytics (intentEvent) {
  if (!intentEvent) return;
  var label = intentEvent.region;
  pageTracker._trackEvent('twitter_web_intents', intentEvent.type, label);
}
 
function tweetIntentToAnalytics (intentEvent) {
  if (!intentEvent) return;
  var label = "tweet";
  pageTracker._trackEvent(
    'twitter_web_intents',
    intentEvent.type,
    label
  );
}
 
function likeIntentToAnalytics (intentEvent) {
  tweetIntentToAnalytics(intentEvent);
}
 
function retweetIntentToAnalytics (intentEvent) {
  if (!intentEvent) return;
  var label = intentEvent.data.source_tweet_id;
  pageTracker._trackEvent(
    'twitter_web_intents',
    intentEvent.type,
    label
  );
}
 
function followIntentToAnalytics (intentEvent) {
  if (!intentEvent) return;
  var label = intentEvent.data.user_id + " (" + intentEvent.data.screen_name + ")";
  pageTracker._trackEvent(
    'twitter_web_intents',
    intentEvent.type,
    label
  );
}
 
// Wait for the asynchronous resources to load
twttr.ready(function (twttr) {
  // Now bind our custom intent events
  twttr.events.bind('click', clickEventToAnalytics);
  twttr.events.bind('tweet', tweetIntentToAnalytics);
  twttr.events.bind('retweet', retweetIntentToAnalytics);
  twttr.events.bind('like', likeIntentToAnalytics);
  twttr.events.bind('follow', followIntentToAnalytics);
});

Please suggest How can I call an ajax page after successful tweet only. I have already tried by calling tweetIntentToAnalytics() function but it’s not capturing after tweeted.

Thanks
Tapas


#2

Unfortunately, no. We don’t provide an event when the tweet was actually posted, only an event when there was a click to open the popup. The code you already have is probably the best guess for analytics.


#3

Actually, we want to provide discount coupon code if user tweets a msg, as per your current functionality user can open the popup and then close it without writing the message.
Is there any way to track that user actually posted the message ?

Thanks
Tapas


#4

You’d have to know the username, and then use the search or timeline API to check whether the message was posted.


#5

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.