When trying to promote your iPhone app it helps to know which efforts are actually producing a result. It’s little tricky with iPhone apps to know which ads or promotions are converting into actual sales, thanks to the black box that is the App Store. However, it is possible using LinkShare. I found the process a little under-documented, so I’ll describe the necessary steps.

Step 1: Sign up as an iTunes Affiliate

First you’ll need an affiliate account, so go to Apple’s iTunes Affiliates page and click on “Apply to be an affiliate,” which will take you to LinkShare. The sign up process asks for your company and website information.

You’ll need to apply to advertise for “Apple iTunes.” I don’t remember how long it took me to be approved, but I think it was less than 24 hours. They do check the website you provided to make sure it is legit. I have heard that they will reject your application if the website is just a placeholder or if it has trademarked names in the URL, such as “iPhone.”

You need a LinkShare account because Apple has provided LinkShare hooks into the App Store so it knows when a click turns into an actual sale. As a bonus you’ll earn a 5% commission.

Step 2: Create a LinkShare link for your app

Next, you’ll need to create a LinkShare link to your app in the App Store. Using this link will allow LinkShare to magically know if a click turns into a sale.

In LinkShare, select the Links > Deep Linking menu item, and select Apple iTunes as the advertiser. Enter your app’s iTunes URL in the URL field. Don’t worry about the U1 Value field right now, you can just leave it blank. Click Create Link and copy the resulting URL.

On your product page, wherever you link to your app in the App Store, use your LinkShare link instead. If you stop here, LinkShare will be able to track how many clicks from your product page result in sales. This is useful in itself, but it would be even better if you could track each promotion separately, and know how many sales a specific ad resulted in.

LinkShare supports ad/promotion tracking through “signatures” which is what the U1 Value field above was all about. Signatures are simply a user defined string that are passed to LinkShare via in the u1 URL parameter.

Step 3: Tracking referrers through the product page

When creating ads or links to your product, you’ll probably want to direct potential customers to your app’s product page on your website instead of directly to the App Store. This allows you to provide a video of your app, cross promote other products or services, or actually use HTML formatting. The complication that arises from this is remembering which ad the user clicked on to get to your product page by the time they get to the App Store.

The first step here is to know how the potential customer got to your product page to begin with. The easiest way to do that is to simply add on a URL parameter for the referrer and give each ad or promotion a different parameter value, which we’ll call a “signature.” For example, an ad for Hearts Attack could use this URL:

http://www.orderndev.com/hearts-attack.html?u1=GAD001

Here the referrer parameter name is u1, just to be consistent with LinkShare, and the ad signature is GAD001.

Next, you need to get the ad signature passed on to LinkShare. This is done through the u1 URL parameter, so you will need to modify any LinkShare URLs on your product page based on the signature parameter. You can do this either server side or client side in JavaScript. Dan Wood talks about how to track referrers server side for Mac apps, and his examples can be modified to work here. I chose to modify the LinkShare URLs client side using JavaScript. The basic algorithm is:

  1. Check for the u1 URL parameter. If it exists save it off into a cookie.
  2. Check for the signature cookie. If it exists, append “&u1=signature” to the LinkShare URLs.

At the bottom of my product page, I have code that looks like this:

	<script type="text/javascript">
		saveParameterInCookie('u1', 'hearts-attack-src');
		restoreCookieToParameterInAnchor('u1', 'hearts-attack-src', 'buy-link');
		restoreCookieToParameterInAnchor('u1', 'hearts-attack-src', 'app-store-link');
	</script>

The first line saves the URL parameter named u1 into a cookie named ‘hearts-attack-src.’ The next two lines update anchor tags in the HTML by appending the value of the signature cookie as an URL parameter. The second line says: update the ‘buy-link’ anchor tag by taking the contents of the ‘hearts-attack-src’ cookie as the value for the ‘u1′ parameter and appending it to the anchor tag’s URL.

Here’s the code for implementing saveParameterInCookie and restoreCookieToParameterInAnchor:

function getURLParameter(name) {
	name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");
	var regexS = "[\\?&]"+name+"=([^&#]*)";
	var regex = new RegExp(regexS);
	var results = regex.exec(window.location.href);
	if (results == null)
		return null;
	else
		return results[1];
}

function addParameterToURL(url, name, value) {
	if ( value == null )
		return url;
	return '' + url + '&' + name + "=" + value;
}

function saveParameterInCookie(parameterName, cookieName) {
	var parameter = getURLParameter(parameterName);
	if ( parameter == null )
		return;

	createCookie(cookieName, parameter, 180);
}

function restoreCookieToParameterInAnchor(parameterName, cookieName, anchorName) {
	var cookie = readCookie(cookieName);
	if ( cookie == null )
		return;

	link = document.getElementById(anchorName);
	link.href = addParameterToURL(link.href, parameterName, cookie);	
}

Hopefully the code is self-explanatory. It relies on functions createCookie and readCookie, which I got from this article on JavaScript cookies. I should also point out I am not a professional JavaScripter, so there may be bugs in the code. I make no guarantees about this code.

As complicated as all that might have seemed, you are now tracking potential customers from your ads or promotions, to your product page, to the App Store where LinkShare knows if they are actually buying or not.

Step 4: Tracking the performance of ads or promotions

The final step is viewing the results of your ad or promotion in LinkShare. LinkShare will be able to tell you how many visitors actually made it to the App Store, and how many of those actually bought something. To know how many visitors an ad or promotion is driving to your product page, you’ll need to use something like Mint or Google Analytics.

In LinkShare select the Reports > Advanced Reports menu item. Select the “Signature Activity” report type, and click View Report. You’ll get a table that looks like this:

linkshare-sales.png

The Member ID column is where your ad or promotion signature will show up. It will be whatever you pass to LinkShare via the u1 URL parameter. It also shows how many clicks the link got, and how much sales it generated. As you can see, my ads aren’t doing so hot, but at least I know that now.