Following on from my earlier tutorial on Tweet Button Callbacks, I’ve expanded on how you can track tweets on your website or application using Web Intents and the Twitter API. With a few lines of JavaScript code, you can update your website to capture tweets and then expand this to save the information somewhere, like incrementing a counter in your database.
You can customise the tweet button anyway you like – in my example, I’ve created a simple Tweet link and a image link to demonstrate this. Including the twitter JavaScript library on your page and binding a callback to the tweet
event will then allow your page to ‘listen’ out for tweets.
Sample Code:
The sample code below shows just how easy it is to listen for the tweet
event:
The sample code includes two examples of twitter buttons you can create: one with just text, and one with a link and text. You can add other options to the tweet buttons too, like replies and retweets. A full list of supported parameters can be found here.
Demo:
You can see a (slightly modified) working example of the code on jsbin.com. This modified version displays a JavaScript alert popup when a tweet from the page is detected, but you can also keep your JavaScript console option to see a log of what is returned by Twitter when a user tweets.
Nice – but have you tried it in Internet Explorer?
It doesnt fire the “twttr.events.bind(‘tweet’, function( event ) {“.
Any other Browser works.
Which version of IE did you try this on?