Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 158
  • Last Modified:

Finding a way to track click throughs without losing http_referer

At my travel site (see www.travelinbc.com/vancouver.cfm) the <a href> for many of the listings go to logit.cfm.  (e.g. includes/logit.cfm?id=113&type=1&site=http://www.collegehostel.com/)

However, logit.cfm uses cflocation (in a cfc) which strips the http_referer value.  This in turn does not allow the analytics program at the destination website to register the value.  

What I'm looking for is a new way to register the click through as is done currently but also redirect the click through in a way that lets the receiving website see it.

The version of ColdFusion is 7.0 MX

From an SEO perspective, the cflocation code is not letting the other website see the click through.  We want that, but we want the stats in our database.

One theory that I've heard is that we should be able to do this with javascript so that when an on click event occurs, the INSERT could be run without interfering with the http_referer.
logit.txt
cfc-func-cflocation.txt
0
quokkasys
Asked:
quokkasys
  • 7
  • 5
  • 3
  • +3
1 Solution
 
gheistCommented:
Most likely you need to include code of logit.cfm in a page (or plainly log referer in access logs?) to capture referer without adding extra burden on a customer browser.
BTW Coldfusion 7 is EOL for couple of years.
Macromedia ColdFusion       7.x.x               2/7/2005       2/7/2010       2/7/2012
If you read intro paragraph of this:
https://en.wikipedia.org/wiki/ColdFusion_Markup_Language
You might save some cent on upgrade.
0
 
quokkasysAuthor Commented:
Upgrading CF is not a viable option at this time.  In addition, my assumption is that the entire logit.cfm code has to be replaced because cflocation regardless of version strips the http_referer.
0
 
gheistCommented:
Referer: only arrives to main page reached, images and other page components are loaded from that page and have it as a referer. It should be possible to use standard access log to collect referers.
0
Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
Jason C. LevineNo oneCommented:
What I'm looking for is a new way to register the click through as is done currently but also redirect the click through in a way that lets the receiving website see it.

cflocation is not your friend here.  Not sure if there is an answer that will work that allows you to continue using it.  What you could do is a convoluted double redirect: Send the click to logit.cfm, then have logit send to a second script that does a simple javascript window.location or or <meta http-equiv="refresh" content="<2;url=http://go.somewhere.com>"> or other form of AJAX action to send the user on their way.
0
 
quokkasysAuthor Commented:
Yes. I am assuming cflocation has to go away. Is there any javascript that could fire off the cfm or cfc function while leaving the a href as normal?

E.g. Onclick event -> does INSERT INTO independently of the a href.
0
 
RobOwner (Aidellio)Commented:
From purely the javascript side (my CF is VERY limited).

I'm going to use jQuery to simplify the javascript, you will need to include this tag in the head section of your site:
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>

I'm going to assume you have a simple CF script that takes does the INSERT INTO when the link is clicked:

Demo here: http://jsbin.com/socoyu/1/edit?html,js,console,output

Also within <script> tags:

$(function() {
	$('a').on('click', function(e) {
		e.preventDefault();
		var me = this;
		$.ajax({
			url:'update_db_cf_script.cfm',
			data: {
				name: 'value go here',
				nextvar: 'something else'
			},
			method: 'POST',
			success: function(data) {
				// this is called after the script has completed and updated the database
              console.log($(me).attr('href'));
				//$(me) is the original link
			}
		})
	});
});

Open in new window

0
 
quokkasysAuthor Commented:
To Rob:

IDEA:  Let's go pure Javascript on this.  Can an <a href> that looks like this:

<a href="http://www.seaviewbeachresort.com/" name="544" onClick="LogFunction();">Seaview Beach Resort</a>

have the LogFunction write "544,2014-11-30 09:09:59" to a clicklog.txt text file on the server?  The 544 is the unique identifier and the current date and time.

This would eliminate Coldfusion calls completely and I could write a batch process interrogate the log file and load the data I need.  That does is not required in real time.

At this point my javascript skills fall off the ledge.  I worry about contention to the log file as lots of people could be calling the javascript function at the same time.  Can you help?
0
 
RobOwner (Aidellio)Commented:
quokkasys,

Let's see how we go.

 JavaScript runs on the client so consequently does not have access to your server.  JavaScript will need to call (via ajax) a server side scripting language e.g. ColdFusion/php/asp/whatever and that script had to write the log file.
As you're using ColdFusion, create a simple script that takes a request parameter and writes it to a file. JavaScript passes the variable via ajax.
Does that make sense so far?
0
 
quokkasysAuthor Commented:
It makes sense, but where I run a-ground is with Coldfusion.  I don't know how to run something server side without posting to a .cfm.  This tends to interfere with the a href post to another page.  Is there a way to execute a script without posting to a CFM?  I can write the CF code, but how does javascript -> Ajax -> Coldfusion?
0
 
RobOwner (Aidellio)Commented:
We will need to post to a .cfm but it will be done via ajax meaning the page doesn't reload, it does it in the background (asynchronous).  Let's give that a try.  I'd also suggest we use jQuery as it will make this process VERY simple (which is nothing but pure javascript http://www.experts-exchange.com/Programming/Languages/Scripting/JavaScript/A_12264-Javascript-Frameworks-what-are-they.html).

Please refer back to my comment above http:#a40472722 as I would only be repeating it again here.  That code is javascript -> Ajax -> Coldfusion
0
 
gheistCommented:
You can store entrance page in a session parameter or hash it into user cookie, then reuse it where needed.
0
 
_agx_Commented:
(no points, I've gotta run ...)

I agree with Rob. You could easily adapt his example to send the information to a cfc. Then perform the db insert (or whatever you need) inside the cffunction.   Here's an adaptation of Rob's example. It invokes a cfc method and writes the 2 parameters to a file. Obviously you can change the cffunction to do whatever you want.

JQuery:
<script src="https://code.jquery.com/jquery-2.1.1.min.js"></script>
<script type="text/javascript">
$(function() {
	$('a').on('click', function(e) {
		e.preventDefault();
		var me = this;
		$.ajax({
			url:'/path/to/YourComponent.cfc?method=logClick',
			data: {
                                // note - the parameter names should match the cfargument names 
				linkClicked: $(me).attr('href'),
				someParam: $(me).attr('name')
			},
			method: 'POST',
			success: function(data) {
				alert('done');
				// this is called after the script has completed and updated the database
              console.log($(me).attr('href'));
				//$(me) is the original link
			},
			error: function (content) {
		        alert(content.responseText);
		    }			
		})
	});
});
</script>                                          

<a href="http://blahblah.com name="544">Click to test</a>

Open in new window


/path/to/YourComponent.cfc

<cfcomponent>
	<cffunction name="logClick" access="remote" returntype="void" output="false">
		<cfargument name="linkClicked" type="string" required="true" />
		<cfargument name="someParam" type="string" required="true" />
		
		<!--- for demo purposes, just log the values to a file --->
		<cfset local.text = now() &": linkClicked="& arguments.linkClicked &"&someParam="& arguments.someParam>
		<cffile action="append" file="c:/temp/logClick.log" output="#local.text#" />

		<!--- do database insert, etc... here ---->
	</cffunction>
</cfcomponent>

Open in new window

0
 
RobOwner (Aidellio)Commented:
Thanks _agx_! :-) I wouldn't know where to begin with cf.
0
 
_agx_Commented:
@RobJurd - You're welcome :)
0
 
quokkasysAuthor Commented:
I am going to work on testing a combination of these ideas over the weekend.  I will report back with results.  Thanks for your help.
0
 
RobOwner (Aidellio)Commented:
No problem. Any clarification you need, just ask.
0
 
GaryCommented:
I've requested that this question be closed as follows:

Accepted answer: 500 points for Rob Jurd's comment #a40472722

for the following reason:

This question has been classified as abandoned and is closed as part of the Cleanup Program. See the recommendation for more details.
0
 
quokkasysAuthor Commented:
Please do not close this question as I have yet to test or implement the code suggestions due to Christmas and New Year's holidays and staff shortages.  My target is Jan 10/15.  Please advise.
0
 
quokkasysAuthor Commented:
Please take my previous note as an objection.
0

Featured Post

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

  • 7
  • 5
  • 3
  • +3
Tackle projects and never again get stuck behind a technical roadblock.
Join Now