Advertisement:

Author Topic: Click counter on HTML Image?  (Read 5506 times)

Offline OzzyMozzy

  • Jr. Member
  • **
  • Posts: 151
Click counter on HTML Image?
« on: April 27, 2012, 09:27:24 PM »
Hi, I'm using SMF 2.0.2 with SimplePortal. I have a left block Custom HTML that is an image members can click on to take them to a web page.

I want to be able to count how often the image is clicked on, can this be done? I would also like it if only i could see the count.

Offline Labradoodle-360

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 12,208
  • Gender: Male
    • matthew.kerle on Facebook
    • Labradoodle-360 on GitHub
    • @matthew_kerle on Twitter
Re: Click counter on HTML Image?
« Reply #1 on: April 27, 2012, 09:30:28 PM »
It'd have to be a custom PHP block, and you'd have to integrate it with $modSettings, or a database table of some sort.
Former SMF Developer
My Modifications

Offline ApplianceJunk

  • SMF Hero
  • ******
  • Posts: 3,407
    • ApplianceJunk.com
Re: Click counter on HTML Image?
« Reply #2 on: April 27, 2012, 09:30:52 PM »
One way would be to use https://bitly.com/.

Create a shorten link with https://bitly.com/ and use it in place of the regular link.
https://bitly.com/ will track the stats for you.

Offline Old Fossil

  • SMF Friend
  • SMF Super Hero
  • *
  • Posts: 10,973
  • Gender: Male
  • Fussy Old Sod
Re: Click counter on HTML Image?
« Reply #3 on: April 27, 2012, 09:31:00 PM »
Hi OzzyMozzy

As this is a portal themed question you should ask in the mods support topic or on www.simpleportal.net

I myself am not sure if or how this could be done however I know someone at the above link will be in a better position to help.

Offline ApplianceJunk

  • SMF Hero
  • ******
  • Posts: 3,407
    • ApplianceJunk.com
Re: Click counter on HTML Image?
« Reply #4 on: April 27, 2012, 09:34:50 PM »
I see no reason why https://bitly.com/ won't work for them.

Offline OzzyMozzy

  • Jr. Member
  • **
  • Posts: 151
Re: Click counter on HTML Image?
« Reply #5 on: April 27, 2012, 09:53:40 PM »
Thanks for that link, i signed up to have a look. It talks about shortening the link but how does it work to track the clicks on my image?

Offline ApplianceJunk

  • SMF Hero
  • ******
  • Posts: 3,407
    • ApplianceJunk.com
Re: Click counter on HTML Image?
« Reply #6 on: April 27, 2012, 10:03:54 PM »
A image link would look something like this...

Code: [Select]
<a href="http://website.com"><img src="http://YourImageURL.com"></a>
You would use https://bitly.com/ to create a new shorten link for http://YourImageURL.com

Then replace http://YourImageURL.com with the new shorten link bitly.com gives you.

Go back to bitly.com to view the clicks and other stats on the new shorten link you are using.

Offline OzzyMozzy

  • Jr. Member
  • **
  • Posts: 151
Re: Click counter on HTML Image?
« Reply #7 on: April 27, 2012, 10:09:41 PM »
Ah i get it now and just tried it out, thanks heaps for that.

Will it count it if the same link was somewhere else? or does it only count it from my web site?

Offline ApplianceJunk

  • SMF Hero
  • ******
  • Posts: 3,407
    • ApplianceJunk.com
Re: Click counter on HTML Image?
« Reply #8 on: April 27, 2012, 10:18:55 PM »
Ah i get it now and just tried it out, thanks heaps for that.

Will it count it if the same link was somewhere else? or does it only count it from my web site?

I believe it will count the shorten link it creates from anyplace it's clicked on.

I use them in emails and they get tracked.

Offline OzzyMozzy

  • Jr. Member
  • **
  • Posts: 151
Re: Click counter on HTML Image?
« Reply #9 on: April 27, 2012, 10:28:45 PM »
So it will only click the shorten link and not count the long link that will be on other web sites?

Offline ApplianceJunk

  • SMF Hero
  • ******
  • Posts: 3,407
    • ApplianceJunk.com
Re: Click counter on HTML Image?
« Reply #10 on: April 27, 2012, 10:34:49 PM »
It only tracks the new shorten link you created.

Offline OzzyMozzy

  • Jr. Member
  • **
  • Posts: 151
Re: Click counter on HTML Image?
« Reply #11 on: April 27, 2012, 10:42:12 PM »
Sweet, thought so i just wanted to confirm, im new to all this. Thanks heaps again it's working and it's perfect...

Offline ApplianceJunk

  • SMF Hero
  • ******
  • Posts: 3,407
    • ApplianceJunk.com
Re: Click counter on HTML Image?
« Reply #12 on: April 27, 2012, 10:43:21 PM »
I'm no expert with it, so this may help answer a lot of your questions better then I can.

https://bitly.com/pages/help

Offline ApplianceJunk

  • SMF Hero
  • ******
  • Posts: 3,407
    • ApplianceJunk.com
Re: Click counter on HTML Image?
« Reply #13 on: April 27, 2012, 10:44:20 PM »
Sweet, thought so i just wanted to confirm, im new to all this. Thanks heaps again it's working and it's perfect...

Glad I could help. :)

Offline OzzyMozzy

  • Jr. Member
  • **
  • Posts: 151
Re: Click counter on HTML Image?
« Reply #14 on: May 01, 2012, 08:00:45 AM »
I have noticed the click count on bitly is way over the top and found that the links are getting hit by bots. I was watching them and each one of the 4 i have each got a click counted all at the same time.

So yes this bitly works but it gives a false reading in my case as i don't want to count bots just real clicks..

Offline Colin

  • Customizer
  • SMF Hero
  • *
  • Posts: 6,713
  • Gender: Male
  • SMF Customizer
    • colinschoen on GitHub
Re: Click counter on HTML Image?
« Reply #15 on: May 01, 2012, 11:26:13 PM »
Yes, that is going to require some PHP if you want to filter out bots and some you won't be able to.
"If everybody is thinking alike, then somebody is not thinking." - Gen. George S. Patton Jr.

Offline OzzyMozzy

  • Jr. Member
  • **
  • Posts: 151
Re: Click counter on HTML Image?
« Reply #16 on: May 01, 2012, 11:51:13 PM »
I have now tried a couple that replace my image link with their own URL to count which is fine but they don’t filter bots.

Isn’t there any programs out there that is simple and easy to use that will do the job?

MrPhil

  • Guest
Re: Click counter on HTML Image?
« Reply #17 on: May 02, 2012, 11:03:21 AM »
If you want guests' clicks to count too, and not just logged-in members, you're going to have to look at the user agent ($_SERVER['HTTP_USER_AGENT']) and weed out anything that sounds like a bot or not a known browser. This could be after the click, or simply displaying an image instead of a link. Keep in mind that it's not foolproof, as some bots pretend to be well-known browsers (to prevent just this sort of action). If you want to ignore guests (as well as bots), you could add code to only display the link for members.