We use cookies to improve your experience. No personal information is gathered and we don't serve ads. Cookies Policy.

ExpressionEngine Logo ExpressionEngine
Features Pricing Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University
Log In or Sign Up
Log In Sign Up
ExpressionEngine Logo
Features Pro new Support Find A Developer
Partners Upgrades
Blog Add-Ons Learn
Docs Forums University Blog
  • Home
  • Forums

Click Tracker

Development and Programming

EE lover's avatar
EE lover
50 posts
about 20 years ago
EE lover's avatar EE lover

>I can also tell you that I experimented with stricter click/spam counts and >came up with two models: >first, you can store many IPs … >Second, you can store each unique click in a table.

Rob1, which one was your choice if any?

       
EE lover's avatar
EE lover
50 posts
about 20 years ago
EE lover's avatar EE lover

I my self prefer the first way.

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
about 20 years ago
Robin Sowell's avatar Robin Sowell

The spam check is the simplest one- the whole thing only uses a single table. Basically, it looks like:

UPDATE exp_clicks SET link_clicks = (link_clicks + (ip <> ‘$request_ip’)) , link_m_clicks = (link_m_clicks + (ip <> ‘$request_ip’)) ,link_spam_clicks = (link_spam_clicks + (ip = ‘$request_ip’)) , ip = ‘$request_ip’ WHERE link_url=’$url’ AND article_id=’$art_id’

Which is straight off of Skeltoac original code. All it does is enter the ip of the last click to the link. Then, if the same ip clicks the link again, it counts it as spam instead of a click. Now, if a different ip is clicked and then someone comes back and clicks it again, it will increment as a legit click.

So, it’s really not a massively secure check on spam. I did have an early version that kept the ip’s in a seperate table- and pretty much saved them forever. BUT that table would get very large very quickly and it personally didn’t seem like enough of an issue to make it worth adding the overhead.

Now Skeltoac suggested:

“The trick to doing this efficiently is to hash the URL and IP together with CRC32 ($HURLIP=crc32($URL.$IP);), storing that value in a column HURLIP INT NOT NULL UNIQUE.”

I’m not familiar with crc32, but the logic’s straightforward so I could do it easily enough. Think I’d do it by link id rather than url, though. For me, the same ulr COULD be counted twice if they were linked in different articles (which happens with me). I like to be able to use the article as the unit of analysis rather than the url. (Hence I added “AND article_id=’$art_id’” to the original code- the urls are not necessarily unique the way I did it- and I didn’t want them to be. Someone wants a summary measure based on url, it’s easy enough to do, but if you only collected data for the url, you couldn’t then break it out by article if the same url was associated with more than one article- which is the case on my site.)

Um…. Long way of saying, if the more secure spam check is really important to folks, chime in and I’ll add it. It’s not hard, but it does add a bit more overhead and I just didn’t think it would be enough of an issue to warrant it.

       
Skeltoac's avatar
Skeltoac
3 posts
about 20 years ago
Skeltoac's avatar Skeltoac

Rob, The first method is very easy to implement. Adding just one extra IP column reduces the chances of repeat clicks by MORE THAN HALF. The queries don’t take much longer and if you’re storing the IPs as 32-bit INTs instead of TEXT columns, the table size suffers very little. The PHP function to convert IPs to integers is ip2long(). Andy

       
Vik's avatar
Vik
209 posts
about 20 years ago
Vik's avatar Vik

Hi Rob,

I’m looking forward to getting it working, and I’m happy to be a beta tester for it.

I installed the latest version, clicked a link, and ran the report page. I got this message:

<br />
<b>Notice</b>:  ob_end_clean(): failed to delete buffer. No buffer to delete. in
 <b>/home/bigpi2/public_html/exp/system/core/core.template.php</b> on line 
<b>1322</b><br />

How can I fix this?

       
Vik's avatar
Vik
209 posts
about 20 years ago
Vik's avatar Vik

I’m not getting that error any more. I got it one time, but it hasn’t come up again. However, currently I’m just getting a blank page when I call up the click tracker report. Can I provide additional info to assist in determining how to correct this?

       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 20 years ago
Lisa Wess's avatar Lisa Wess

Just as an fyi, Yoshi’s linklist module now includes click tracking for those links. This module would be great for links in entries, of course. =)

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
about 20 years ago
Robin Sowell's avatar Robin Sowell

Hey Vic, thanks for checking the newest version. I need to deinstall and the re-up everything that was in the latest zip to see if I can replicate the error. At the moment, I can’t.

The obflush should only occur if you access the hit template directly, rather than having it called via a link. I can’t replicate it otherwise.

As to the display…. Like I say, I’ll need to reinstall everything and replicate the problem. Are the numbers being added to the database and the tags simply not displaying them? Or is nothing getting added, so there’s nothing to display?

Also, some changes to the parameters and to variable names. For example, if you set a weblog in the parameter, only entires for which an id is entered will be shown. Also, double check you changed the variable names.

The below seems to be working fine for me:

<table border=”1”><tr> <td>entry_id</td> <td>link_title</td> <td>link_url</td> <td>link_clicks</td> <td>link_m_clicks</td> <td>link_spam_clicks</td> <td>article_title</td> <td>weblog</td> <td>comment_auto_path</td> <td>date</td> <td>permalink</td> <td>comment_entry_id_auto_path</td> <td>comment_url_title_auto_path</td> <td>percent</td> </tr>

{exp:clickport:clickport limit="50" sort="desc" orderby="link_clicks" weblog="all" percent="yes"} {exp:clickport:linkconvert entry_id="{entry_id}”} <tr> <td>{if entry_id == "0"}No article{/if}{if entry_id != "0"}{entry_id}{/if}</td> <td>{if link_title}{link_title}{/if}{if link_title == ""}No title{/if}</td> <td><a href=”{link_url}”>link</a></td> <td>{link_clicks}</td> <td>{link_m_clicks}</td> <td>{link_spam_clicks}</td> <td>{article_title}</td> <td>{weblog}</td> <td>{comment_auto_path}</td> <td>{date format="%Y %m %d %a"}</td> <td> {permalink="weblog/blah"}</td> <td>{comment_entry_id_auto_path}</td> <td>{comment_url_title_auto_path}</td> <td>{percent}</td> </tr> {/exp:clickport:linkconvert} {/exp:clickport:clickport} </table>

But I’ll take a look at it with fresh eyes tomorrow. Maybe I uploaded an old file in the zip by accident!

       
Vik's avatar
Vik
209 posts
about 20 years ago
Vik's avatar Vik

It may just be a miscommunication about how to install it. I had he previous version working, so the javascript must be getting called correctly. Here’s what I have in my Click_Report template:

<table>
{exp:clickport:clickport limit="50" sort="desc" orderby="link_clicks" weblog="all" percent="yes"}
{exp:clickport:linkconvert entry_id="{entry_id}"}
<tr>
<td>{if entry_id == "0"}No article{/if}{if entry_id != "0"}{entry_id}{/if}</td>
<td>{if link_title}{link_title}{/if}{if link_title == ""}No title{/if}</td>
<td><a href="{link_url}">link</a></td>
<td>{link_clicks}</td>
<td>{link_m_clicks}</td>
<td>{link_spam_clicks}</td>
<td>{article_title}</td>
<td>{weblog}</td>
<td>{comment_auto_path}</td>
<td>{date format="%Y %m %d %a"}</td>
<td>{comment_entry_id_auto_path}</td>
<td>{comment_url_title_auto_path}</td>
<td>{percent}</td>
</tr>
{/exp:clickport:linkconvert}
{/exp:clickport:clickport}
</table>

Currently I have tried calling the template directly via a URL; it results in an sql error. I tried calling the template via a link on my home page, and also got the sql error.

Do I have the correct code in the Click_Report template? Is there a different way I should be installing it?

       
Vik's avatar
Vik
209 posts
about 20 years ago
Vik's avatar Vik

Whoa! I just rebooted my computer after installing new software, called up the click report page, and it reported correctly with no errors! It must have been some sort of caching thing. Now I can experiment more with the latest code. I’ll post here when I have more info.

       
Robin Sowell's avatar
Robin Sowell
13,158 posts
about 20 years ago
Robin Sowell's avatar Robin Sowell

Heh- glad you got it working. I’ve been obsessing over some preg that’s got me stuck. Took it over to module support forum, so hopefully I’ll get it squared away. Once that’s done, should have a new version up pretty soon.

It’s getting there- I just keep adding more stuff.

       
Vik's avatar
Vik
209 posts
about 20 years ago
Vik's avatar Vik

Great! I’m looking forward to seeing it.

       
EE lover's avatar
EE lover
50 posts
about 20 years ago
EE lover's avatar EE lover

me too!

       
Vik's avatar
Vik
209 posts
about 20 years ago
Vik's avatar Vik

It’s working! It’s really great. Way to go. Rob!

I notice it even captures clicks to links that aren’t inside of {exp:weblog:entries} tag pairs, for example, my blogroll, which is great.

I think if you access the click report before anybody has actually clicked a link, you get an sql error.

Here’s my Click Report template in case others may find it useful:

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
        "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <link rel='stylesheet' type='text/css' media='all' href='{stylesheet=weblog/weblog_css}' /> 
    <style type='text/css' media='screen'>@import "{stylesheet=weblog/weblog_css}"
    ;</style>

    <title>Click Report</title>
</head>
<body>

<table border="1">
<tr>
<td><center><b>Entry ID</center></b></td>
<td><center><b>Clicks</center></b></td>
<td><center><b>Article Title</center></b></td>
<td><center><b>Link </center></b></td>
<td><center><b>Date</center></b></td>
<td><center><b>%</center></b></td>
</tr>


{exp:clickport:clickport limit="50" sort="desc" orderby="link_clicks" weblog="all" percent="yes"}
{exp:clickport:linkconvert entry_id="{entry_id}"}
<tr>
<td>{if entry_id == "0"}<center>--</center>{/if}{if entry_id != "0"}{entry_id}
{/if}</td>
<td>{link_clicks}</td>
<td>{if entry_id == "0"}<center>--</center>{/if}{if entry_id != "0"}
<a href="{comment_entry_id_auto_path}">{article_title}</a>{/if}</td>
<td><a href="{link_url}">{link_url}</a></td>
<td>{date format="%Y %m %d %a"}</td>
<td>{percent}</td>
</tr>
{/exp:clickport:linkconvert}
{/exp:clickport:clickport}
</table>

</body>
</html>
       
Lisa Wess's avatar
Lisa Wess
20,502 posts
about 20 years ago
Lisa Wess's avatar Lisa Wess

Just as a note, if yo uuse the linklist module, it now tracks click-thrus and has tags for displaying that information. =)

       
1 2 3 4

Reply

Sign In To Reply

ExpressionEngine Home Features Pro Contact Version Support
Learn Docs University Forums
Resources Support Add-Ons Partners Blog
Privacy Terms Trademark Use License

Packet Tide owns and develops ExpressionEngine. © Packet Tide, All Rights Reserved.