1. Advertising
    y u no do it?

    Advertising (learn more)

    Advertise virtually anything here, with CPM banner ads, CPM email ads and CPC contextual links. You can target relevant areas of the site and show ads based on geographical location of the user if you wish.

    Starts at just $1 per CPM or $0.10 per CPC.

Capturing Referrer Using ColdFusion.

Discussion in 'Programming' started by SEOMalc, Jun 6, 2007.

  1. #1
    Hi, I am trying to capture referral data from various sources using ColdFusion such as Google Adwords, Yahoo, MSN, Google etc.

    I have done this in the past using PHP as it allows access to the header variables, but I'm rather rusty when it comes to ColdFusion having only lightly touched on it during me degree many years ago.

    What I need to ask is, is there a way that I can capture the URL a visitor has come to me from using ColdFusion, so I can report back to my superiors and say "this many visitors came from Google Adwords, this many came naturally via MSN, this many came naturally via Yahoo etc." ?

    Thankful for any help anyone can give.

    SEOMalc.
     
    SEOMalc, Jun 6, 2007 IP
  2. IsRoss()

    IsRoss() Peon

    Messages:
    116
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    0
    #2
    Very easy. #cgi.http_referrer# is the variable you are looking for. Then to save it to your database:

    <cfquery name="save_referrer" datasource="#MY_DSN#">
    INSERT INTO referrer_table (referrer_name) VALUES ("#cgi.http_rerferrer#")
    </cfquery>
     
    IsRoss(), Jun 6, 2007 IP
  3. tbarr60

    tbarr60 Notable Member

    Messages:
    3,455
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    210
    #3
    I'd recommend dumping the CGI scope as a learning exercise.

    <cfdump var="#CGI#">

    While your at try dumping application, server, client, session, request, form, variables, or any other scope you have or can think of. It's the best way to see what the server and or browser are seeing.
     
    tbarr60, Jun 6, 2007 IP
  4. 3plains

    3plains Well-Known Member

    Messages:
    45
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    108
    #4
    Thanks for the info tbarr60. Good stuff.
     
    3plains, Aug 20, 2007 IP
  5. tbarr60

    tbarr60 Notable Member

    Messages:
    3,455
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    210
    #5
    I am a big fan of CFDUMP and it even gets better with CF8. I wrote about it on my blog in the post CFDUMP even better in CF8.
     
    tbarr60, Aug 20, 2007 IP
  6. 3plains

    3plains Well-Known Member

    Messages:
    45
    Likes Received:
    2
    Best Answers:
    0
    Trophy Points:
    108
    #6
    Is there any way to capture the Referer/User without storing the value of cgi.http_referer or cgi.http_cookie to a database?

    All I want to do, is grab the variable once, store it (as users still browse your website), then attach it to a contact form that sends to an email address.

    Any help would be appreciated.
     
    3plains, Aug 20, 2007 IP
  7. tbarr60

    tbarr60 Notable Member

    Messages:
    3,455
    Likes Received:
    125
    Best Answers:
    0
    Trophy Points:
    210
    #7
    Read up on client scope and session scope. If you store the variable in either scope you can access it throughout their stay on the site.
     
    tbarr60, Aug 20, 2007 IP
  8. advantage

    advantage Well-Known Member

    Messages:
    1,338
    Likes Received:
    36
    Best Answers:
    0
    Trophy Points:
    140
    #8
    in application.cfm
    <CFPARAM name="session.ref_Url" default="#cgi.http_referrer#">

    Then add session.ref to your send mail script.
    Something like <CFIF isdefined("session.ref_URL")>
    Ref : #session.ref_URL#
    </CFIF>

     
    advantage, Aug 23, 2007 IP
  9. tmusschoot

    tmusschoot Peon

    Messages:
    1
    Likes Received:
    0
    Best Answers:
    0
    Trophy Points:
    0
    #9
    I have tried this and it did not work? Any other suggestions?
     
    tmusschoot, Nov 13, 2009 IP
  10. cfStarlight

    cfStarlight Peon

    Messages:
    398
    Likes Received:
    3
    Best Answers:
    0
    Trophy Points:
    0
    #10
    .. and what do you mean by "did not work"?
     
    cfStarlight, Nov 13, 2009 IP