I have a partner that is going to pass a transactionid to me in the URL when a user clicks on an ad on their site.
I need to postback variables to their site when a user converts.
I have that part coded already using CFHTTP.
My question what is the best way to detect that a user has entered my site with a transactionid and then be able to know that is the same user when they convert.
Is it something like this?
1. Detect transactionid when user enter website in application.cfc
2. If a transactionid is detected - set a session variable like session.transactionid = yes or session.transactionid=12345abc8964
3. If user converts - check for the existence of transactionid session variable.
4. if transactionid session variable exists - postback info the partner site
It almost seems too easy. So I'd thought I'd check with the ColdFusion geniuses.
Question: What does it mean when a user "converts"?
convert means they make a purchase
I have a suggestion that assumes the URL has a query-string. That is, www.mycompany.com?transactionid=12345abc8964
Application.cfc (just the relevant part)
<cfcomponent> <cffunction name="onRequestStart"> <cfargument name = "targetPage" type="String" required="true"> <!--- Implement a modicum of checks: is this the client IP and is there a transactionID in the query-string? ---> <cfif CGI.REMOTE_ADDR is "18.104.22.168" and structKeyExists(url, "transactionid")> <cfset request.transactionid=url.transactionid> </cfif> <!--- ... etc. etc. ---> <cfreturn true> </cffunction> <cfcomponent>
index.cfm or trxnPage.cfm (the transaction landing page in your application)
<cfif structKeyExists(request, "transactionid")> <!--- Do the business involving the transactionID. Its value is request.transactionid. ---> <cfelse> <!--- Do the business involving no transactionID being passed in the URL. ---> </cfif>
You may of course use session.transactionid in place of request.transactionid. I have used request.transactionid on the assumption that the client might need to perform multiple transactions within one session.