Skip to main content
Inspiring
May 28, 2020
Answered

Detect URL Variable - Set Session Variable

  • May 28, 2020
  • 2 replies
  • 1529 views

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.

Like this

www.mycompany.com/transactionid=12345abc8964

 

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.

    This topic has been closed for replies.
    Correct answer BKBK

    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 "123.123.123.123" 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>
    
    

     

    2 replies

    BKBK
    Community Expert
    BKBKCommunity ExpertCorrect answer
    Community Expert
    May 28, 2020

    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 "123.123.123.123" 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>
    
    

     

    BKBK
    Community Expert
    Community Expert
    May 28, 2020

    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. 

    WolfShade
    Legend
    May 28, 2020

    Question:  What does  it mean when a user "converts"? 

    weezerboyAuthor
    Inspiring
    May 28, 2020

    convert means they make a purchase