Tweeting from an Ad on the iPhone Using URL Schemes

Lately I’ve been experimenting with promoting out app 'Friend Focus (for Facebook)' by ‘turning out the vote’ - ie getting our existing users to help us promote Focus. Once I’ve found a formula that works well we’ll implement the scheme in app and figure out a way to reward users for helping us, but for now I’ve been using house ads. House ads are our own ads placed in our app using the ad network we’re integrated with. Admob in this case. This is a great way to try out ad copy and experiment with different promotions because its all done with no code updates to our app, all I have to make is a simple HTML landing page for each ad. A recent campaign we’ve been running is ‘Tweet your support for Focus’, which asks people to tweet saying that Focus is great:

Tweet support for Focus ad

Tweet support landing page

Naturally the tweet has to be pre-filled, which lets me use a link so I can track the effectiveness of the campaign. A ‘tweet me’ link is pretty easy on the web, but this is on people’s iphone. Twitter users with lots of followers (ie the people we want to tweet) aren’t using the twitter website on their iPhone, they’re using a twitter app, of which there are many to choose from! So how do we turn a click on my ad into a pre-filled tweet right inside someone’s pre-logged in twitter app of choice? The solution is to use custom URL schemes. Several iPhone twitter apps have custom url schemes that allow you to launch them and pre-fill a tweet using their custom url. This works just as well from the landing page of an admob, in code in a native app, in a web page in mobile safari, or a link in an email.

Hmmm, but which twitter app to choose? Turns out you can choose them all! I wrote some simple javascript to just open all of them - one of them is bound to hit. The code is below. I picked 5 of the most popular twitter clients and included them. The script works great in the UIWebView that Admob opens to show the landing page for the ad, because the UIWebView isn’t throwing up a dialog saying “couldn’t open that URL” for urls where a scheme isn’t installed on the devide. Its imperfect as a web page because of these alerts, which you will see if you try it. I tried a bunch of things - using the tweet url for an image src, in an iframe, as a form submit. I also played with timers and onblur event to try to cancel out the urls tries upon returning to the page in Safari. If someone could figure out the perfect javascript for this that works in Safari and post here in the comments, that would be very awesome.

Go ahead and try it by clicking the ad above, and if you tweet your support for Focus, that would be splendid! As you can see to the left, it works... we've had 28 tweets so far, from a variety of twitter apps, which has generated 165 click throughs to the Focus website. Thanks to everyone who tweeted for us so far. Below is my hastily put together javascript.

Tweet Focus Support

Tweet Your Support

We need your help to spread the word about Focus for Facebook. If you use Twitter, please take a moment to...

tweet support

tweet support

Mark & Rob, Focused Apps.