NOTE: This page used to redirect automatically after a delay, effectively implementing a really slow redirect page, giving you the reader a chance to stop the redirect and read the contents of this page. The purpose of this page is to demonstrate how to do a redirect using Javascript and a form POST method.
If Commission Junction ever goes forward with a mandatory use of Javascript links, this would be the only possible method to perform a local redirect, used by many affiliates for tracking purposes. In fact, since this page was published, CJ has published a document with this exact same method for the purpose of helping "database publishers" accomplish local redirects. That document is available upon request from their services group.
However, despite the purpose of this page, which is only intended to be accessed when a user willingly clicked on a link that would take them to the intended destiation, CJ's network quality team isn't pleased with it. While they seem to have missed the point, I have stopped the automatic redirect as people may be getting to this page without first clicking on the link that says "visit ebay". If you did click on that link, you'll have to pretend that you would have been automatically redirected.
Also please note that I do not in any way condone forced clicks, sneaky redirects, or cookie stuffing, whether it be done with a script like the one on this page, or any other method. After all, I did help author the Publisher Code of Conduct in 2002 and the update in 2004. Doing any of those things is a sure way to get your publisher account terminated.
In practical use, a redirect page like this wouldn't have that delay timer, and would only contain the short text in the blue-bordered box above.
Click here to see what it's like with no delay timer. You'll notice that there is small pause while the javascript executes and you can see the page (unlike a normal 302 redirect using the regular GET method).
How to do a Redirect to an HTTP POST Request with Javascript
The purpose of this script is to perform a local redirect using Javascript. I wrote it a few days after I heard about the Commission Junction Link Management Initiative, wondering how affiliates would be able to do redirects. This is the only method I could conceive of that possibly conforms to CJ's pending policy of requiring a form POST on any links from webpages.
Note: I have not received confirmation from Commission Junction that this is an acceptible way to link.
If you view the source of this page, there's much more code actually in this page than what is needed, to accomplish the timer and all of this information. The necessary Javascript and HTML simply looks like this:
<body onLoad="submit_form();">
<form name="myform" action="http://www.kqzyfj.com/interactive" method="POST">
<input type="hidden" name="aid" value="111111">
<!-- AID of the CJ link. You would probably pass this into the script in the query string -->
<input type="hidden" name="pid" value="222222"> <!-- your PID -->
<input type="hidden" name="sid" value="your-SID-value"> <!--optional-->
<input type="hidden" name="url" value="http://www.merchant.com/deep-link.html"> <!-- optional -->
<p>You are being redirected automatically.<br />
If not, then you do not have JavaScript enabled.
Please click here: <input type="submit" value="Continue..." /></p>
</form>
<script language="javascript">
<!--
function submit_form()
{
document.myform.submit()
}
-->
</script>
Why is this useful?
In the context of the Commission Junction Javascript links, it's the only way to do a local redirect and conform to CJ's future policy of no plain URLs. They are planning, not until at least 2007, to require only HTTP POST requests on affiliate links through websites.
The way I would use this is similar to how I do local redirects now:
- Call this redirect page with an identifier to look up the link, e.g.:
http://www.domain.com/jsredirect.php?product_id=12334556 - Do any tracking that I need to do, store information in a database of clicks, etc.
- Lookup product ID 12334556 in my product database and get the correct merchant URL (not the Affiliate link, as the form takes care of that part. The URL parameter takes the actual merchant link.) Of course this applies to any usage where there are links in a database -- coupons, merchant lists, etc.
- Serve up this page with all of the appropriate form variables populated.
- If the user has Javascript enabled, they'll briefly see this page, and will then be redirected. If they do not have Javascript enabled, hopefully they will click the form submission button to continue. If 10% of users don't have Javascript enabled, and 10% of them don't click through, that's a 1% loss.
Otherwise, if you have a use for performing a redirect through a form POST, this is the only way to do that. The above example is specific to a Commission Junction link, but of course you can include any form variables in that you wish.