Is there a way to register a callback on Twitter's Tweet button? I'd like to be able to track which particular users on my site have tweeted a link. I can't add on onClick event because it's a cross-domain iFrame. Any other ideas?
I've seen one way to do it but it seems unreliable. Their documentation doesn't mention anything so I am looking for help with a work-around.
Twitter has Web Intent events for
loaded
,rendered
,resize
,tweet
,follow
,retweet
,like
, andclick
.The behavior was changed in the fall of 2015 due to the unreliableness of callbacks happening after an event is complete.
Example loading widgets.js:
Working Example
I have just implemented a tweet callback event.
More information on Twitter's callback event
- Twitter Web Intents
- Web Intents Javascript Events
The Javascript callback
The tweet button:
yes, there is a callback function. for custom twitter buttons as well. you can find it here: https://dev.twitter.com/discussions/671
If you load the Twitter Widgets JS, you can bind a callback function to the tweet event. See the code below: