<!--- 
 Filename:   AdClick.cfm
 Created by:  Nate Weiss (NMW)
 Please Note: This template executes when a user clicks on an ad
--->

<!--- Assuming we have shown an ad on the referring page --->
<cfif structKeyExists(SESSION.adsOnPages, CGI.http_referer)>

 <!--- What ad was last shown to this user on referring page? --->
 <cfset adFileName = SESSION.adsOnPages[CGI.http_referer]>
 
 <!--- 
  At this point, you might record the "click" in database 
  and then redirect the user to the appropriate site via
  the <cflocation> tag. Here, we will simply output the 
  ad that the user clicked on, just to prove the concept.
 --->
 <cfoutput>
  You just came from: #CGI.http_referer#<br>
  You got here by clicking on the <b>#AdFileName#</b> ad.
 </cfoutput>

<!--- If "KeyExists" fails, we don't know what ad was shown --->
<cfelse>

 We don't have any ad on record for you. Perhaps you didn't 
 come here after seeing an ad, or your session timed out. 

</cfif>
