I have modified the WordPress plugin wp_ozh_clickcounter v1.01 so it:
- can be used to track clicks on links/blogroll
- can ignore bots
- can ignore admin clicks
- ignores links to local absolute URLs.
- $wp_ozh_click['do_comments'] = 1
Tracking link/blogroll clicks
wp_ozh_click_modifyhrefs(get_links()) doesn’t work because the default action of get_links is to echo links, not return them. However calling get_links with the 11th parameter set to false will return the links instead of echoing them, eg:
cat_id, ‘<li>’, ‘</li>’, ‘<br />’, FALSE, ‘id’, TRUE, TRUE, -1, true, false)); ?>
However, get_links() returns links with the href wrapped in single quotes, so in addition modifications to the orginal plugin are required. These modifications are included in the version below.
Ignore bots
When a bot crawls a link it will increment the number of clicks. The modified plugin can check to see if a bot is crawling the link and not increment the count.
Set $wp_ozh_click['log_bots'] = 0; (default)
Ignore admin clicks
When the admin user is logged on, the modified plugin can ignore clicks.
Set $wp_ozh_click['log_admin_clicks'] = 1; (default)
Ignore local absolute URL links
If you use the <!–more–> tag in posts, then the link to the rest of the post will be an absolute URL that will be tracked. v1.01fimt ignores absolute local URLs as well as relative local URLs, unless explicity told otherwise by placing the count tag in the link.
Links in comments are tracked by default
$wp_ozh_click['do_comments'] = 1 is set in the plugin. All other settings are the same as v1.01.



Ozh said
Hello
Nice to see some work from my plugin ! The blogroll feature has been long asked but I couln’t be arsed to do it
Anyway I have a suggestion for your bot feature : instead of testing the variable in go.php, it would be smarter to test it in the plugin file when calling the add_filter() function. Indeed, why parse data and modify href’s if it’s not to be used ?
Croaky said
Hey Ozh, Thanks for your comments, I wasn’t sure under what license you have released the orginal code and wasn’t sure if you permitted redistribution of derivative works, but from your response I assume you do?
Great suggestion, if I get around to it I will implement the bot feature in the plugin file as you suggest.
BB said
Is this a fork of the actual plugin? I think these additions were much-needed. Can they be included in the original plugin?
BB said
My website URI was added to the beginning of a tag links within posts before installing this plugin change. The change fixed the first link in a post, but subsequent links still had my URI appended to the beginning.
Croaky said
Hey BB, this is a fork as such, although I am happy for ozh to host this on his site as a new ‘official’ version with some from of attribution, say a link back here. Try contacting him about that.
Croaky said
Hey BB, regarding the URI appended to the beginning, it’s probably something to do with the regex expression. If you provide the raw links (both the one at the start that works and the one that doesn’t) as it appears in the post before it is modified by the plugin I may be able to help.
BB said
Here’s the two links as they appear in 1 (one) post on my WP theme sandbox site:
1.
Spirit v1.5 can be downloaded here.
and further on down the post…
2.
Alternatively, you can use the ContactForm plugin as I have done here.
Croaky said
The first link is to your site so unless you explicitly add the count tag to the link it will not be modified to record clicks. The second URL is external to your site so should be modified to record clicks I think. Does that help?
BB said
Before I upgraded to the latest version of WP, both links were counting clicks. After upgrading, both links appended my URI to the front of the links. As the first one is an internal link, it duped the URI and showed an non-existent link.
After installing your version of the plugin, the first link worked, although no click counting. The second one, as I said previously, still appended my URI to the front of it, and recorded clicks.
I have since disabled the plugin and am trying to figure out how to get it to work properly, as it did before the WP upgrade.
Croaky said
This is the behaviour that I intended, ie: for any URL that is not external, the counting php script (eg: go.php) will not be appended to start of the URL and clicks will not be counted. In order to record clicks on internal links you must explicitly add count=1 to the link in the post eg: <a href=”http://mysite” count=”1″>
BB said
OIC! I understood it backwards, dyslexia I guess. I wanted only internal link clicks to be counted, as I wanted to see how many peeps were d/ling my theme. However, that wasn’t the main problem. The main problem was the duped URIs I mentioned, directing users to nonexistent addresses. Thinking about this, I recall part of the WP upgrade process was to delete all WP files from the root. I’m thinking I may have inadvertently deleted go.php. Could that have caused the duping effect?
Croaky said
I don’t think deleting go.php would cause the duping effect. I remember it occuring in the orginal version of the plugin but (hopefully) I got rid of that by tweaking the regex expression.
]V[orlock Zernebock said
When I activate the plugin I cannot execute “Simple Spoiler” plugin javascript href:
Any way to make both plugins run?
John said
Croaky,
Any idea why I can’t seem to get this plugin to work with the Kimili Flash Embed plugin? Your plugin appears to work fine if I disable the Kimili plugin. I’m running on WordPress 2.0.1. Any help would be greatly appreciated.
-john
Croaky said
Sorry John, no idea, I don’t use either the Kimili Flash Embed plugin or WordPress 2.0.1
Theo Bakker said
Hi, This was exactly what I was looking for.
I was wondering if you have a version that corresponds with version 1.02 of planetOhz.
- Theo