• Global community
    • Language:
      • Deutsch
      • English
      • Español
      • Français
      • Português
  • 日本語コミュニティ
    Dedicated community for Japanese speakers
  • 한국 커뮤니티
    Dedicated community for Korean speakers
Exit
0

Track anchor clicks

Community Beginner ,
May 04, 2006 May 04, 2006

Copy link to clipboard

Copied

I have a one-page newsletter-type website that has several anchor links that I need to try and track when someone selects them.

Any thoughts?

Thanks in advance,
Rob
TOPICS
Advanced techniques

Views

593

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 04, 2006 May 04, 2006

Copy link to clipboard

Copied

Put a page in between the link and the landing page.

In other words. Have the anchor links actually point to a separate page
(passing the anchor along). Then have that page log what anchor was passed
and redirect the user back to the appropriate page and anchor.

--
Bryan Ashcraft (remove brain to reply)
Web Application Developer
Wright Medical Technologies, Inc.
=============================
Macromedia Certified Dreamweaver Developer
Adobe Community Expert (DW) :: http://www.adobe.com/communities/experts/


"etman" <webforumsuser@macromedia.com> wrote in message
news:e3d6p3$b5n$1@forums.macromedia.com...
>I have a one-page newsletter-type website that has several anchor links
>that I need to try and track when someone selects them.
>
> Any thoughts?
>
> Thanks in advance,
> Rob


Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 04, 2006 May 04, 2006

Copy link to clipboard

Copied

I thought of that too, but I'd like to avoid loading extra pages if necessary.

What about this:
1. person clicks on an anchor
2. Same page loads but at the top is some CF: registers anchor link clicked and if anchor is different than session variable (or session variable is empty) it registers a hit, updates the session variable and then goes down to said anchor.

I'm close to getting this to work, I just need to get the redirect to work cleanly. I'd like to limit the number of times pages reload if possible.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 04, 2006 May 04, 2006

Copy link to clipboard

Copied

If an anchor is clicked, you can use the cgi.http_referrer variable to do your count. Of course, users can hide that from you, so you might miss some.

You could attach url variables, but, if the user bookmarks the target page, you might double count.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 04, 2006 May 04, 2006

Copy link to clipboard

Copied

But isn't cgi.http_referrer where you're coming from? I want to track where you're going to.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
LEGEND ,
May 04, 2006 May 04, 2006

Copy link to clipboard

Copied

quote:

Originally posted by: etman
But isn't cgi.http_referrer where you're coming from? I want to track where you're going to.

If you use it on your target page, you know that the user got there by using a hyperlink.

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Contributor ,
May 05, 2006 May 05, 2006

Copy link to clipboard

Copied

Use CF and JavaScript. Create the cookie initially with CF. Update the cookie when user clicks with JavaScript. Read the updated cookie on every page load with CF using your APPLICATION.CFM file. Write the value to a DB, etc. Copy the below and run. Should be what you need. You might need more error checking, I concentrated on functionality. The onLoad() in the BODY tag initializes the JavaScript input box counter and is not required. If not needed, remove the onLoad() call, the initializeKounter() function and one line from updateCookie() (which is commented).

You owe me a beer


<cfparam name="COOKIE.ANCHOR_KOUNTER" default="0">

<cfoutput>
CF anchor cookie count: #cookie.anchor_kounter#<br>
</cfoutput>

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">

<html>
<head>
<title>Untitled</title>

<script language="JavaScript">
function updateCookie() {
var name = 'ANCHOR_KOUNTER';
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
var new_kount = unescape(dc.substring(begin + prefix.length, end)) - 0 + 1;
document.cookie = "ANCHOR_KOUNTER="+new_kount;
window.document.myform.kount.value=new_kount; //take out this line if you delete the <form>
}

function initializeKounter() {
var name = 'ANCHOR_KOUNTER';
var dc = document.cookie;
var prefix = name + "=";
var begin = dc.indexOf("; " + prefix);
if (begin == -1) {
begin = dc.indexOf(prefix);
if (begin != 0) return null;
} else
begin += 2;
var end = document.cookie.indexOf(";", begin);
if (end == -1)
end = dc.length;
var curr_kount = unescape(dc.substring(begin + prefix.length, end));
window.document.myform.kount.value=curr_kount;
}
</script>
</head>

<body onload="initializeKounter();">
<form name="myform">
javascript cookie count: <input type="text" name="kount" size="5">
</form>

<a href="##boo" onclick="updateCookie()">click to goto anchor</a>
<table height=200>
<tr>
<td>words
</td>
</tr>
</table>

<a name="##boo">anchor</a>



</body>
</html>

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Community Beginner ,
May 06, 2006 May 06, 2006

Copy link to clipboard

Copied

LATEST
I'll have to check this out. If it works as well as I think I owe you two beers

Votes

Translate

Translate

Report

Report
Community guidelines
Be kind and respectful, give credit to the original source of content, and search for duplicates before posting. Learn more
community guidelines
Resources
Documentation