Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Tracking on every page

Status
Not open for further replies.

Bramvg

IS-IT--Management
Jan 16, 2001
135
BE
Hi,

On my website I would like to track every page a visitor clicks on. I give every page a Page ID e.g. A5 and I know the ID of my visitor: e.g. 15

Now, I can do this using an INSERT statement on every page, but I would like to centralize this.
Let's say: I would like to put on every page something like:
<cfset pageid=&quot;A5&quot;>

Is it possible to put in the application.cfm a insert statement which 'reads' my 'pageid' and insert into my database?

Does anyone has an alternative for putting an Insert statement on EVERY page?

Thanks for the help, again ;-)
bram


 
Hey Bram,

It sounds like you know how to track everything and handle the insert so I won't address that. Your real problem lies in the fact that each page can set it's own id at the top but this will occur AFTER any code in your application.cfm is run. What you could do is either put an include or a custom tag at the top of every page that calls a centralized function to do your tracking. The only problem is that you have to put your code at the top of every page and change the id on every page to a distinct id. This isn't as nice because you can't change it in one place and you have to set individual ids on every page.

Another solution that's a little more involved would be to put it in the application.cfm file but check the variable &quot;cgi.script_name&quot; to see what page is currently running. You could then look this up in a table, retrieve the page's id, and do your insert. This allows your code to be maintained in one place and the id's to be stored in a single table. This approach requires a little finese as you have to contend with scripts named the same in different directories and such but does make it a little easier to maintain and implement especially across an existing code base.

Hope this helps,
GJ
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top