How to count button clicks on a web site
December 29, 2016 10:26 AM   Subscribe

I have a free Wordpress site on which I want to display a button (or a link) saying "Take action," and above that, the number of people who have clicked it, e.g. "53 people have taken action." Clicking on the button should update the count and take the user to a thank you page. Assume total ignorance of HTML, Wordpress, and whatever else I would need to know to do this.

I'm hoping that there's a simple way to do this - one of the built-in Wordpress tools or copy-and-pasting some code - but if absolutely necessary I can attempt to educate myself enough to pull it off.

In case you are wondering, this is to track the number of people who have sent copies of Hiroshima to the White House.
posted by sunset in snow country to Computers & Internet (4 answers total)
Does the button automatically send a copy? Can you provide a little more about how this website works? If you're trying to count how many people have done $thing on your website there are probably more elegant and accurate ways to do it. Off to see if you have a link anywhere...
posted by chesty_a_arthur at 10:49 AM on December 29, 2016

I'm asking people to send physical copies of the book through USPS, so the button is just an honor-system way to say "I sent a book!" so that I (and other visitors) can see how many people have sent one.
posted by sunset in snow country at 11:03 AM on December 29, 2016

Assuming you're talking about the free, keep in mind you're not allowed to upload plugins or custom functions. I suggest opening a support ticket with the Happiness Engineers, they've likely encountered this request and have options for solutions for you :)
posted by Meagan at 11:19 AM on December 29, 2016

This might be a little more complicated than it seems.

The problem is this can't really be stored just in the webpage code, which is a unique state for each client browsing. You need to store that number somewhere else to share it amongst all clients. The typical location would be a database, i.e. MySQL, MongoDB, etc.

Then it's just a matter of figuring how to connect the button click event to updating that number wherever it is stored.

But beyond that, you probably need a way to control how many times someone can click that button. Do they need to be a registered user to click? Or will you store a cookie in the client for that session to prevent them from clicking again? Or how would you prevent a bot that comes in and clicks it 1000 times?
posted by doomtop at 8:18 AM on December 30, 2016

« Older Tropical Bathroom Decorating   |   Apple Health Pedometer for Android Newer »
This thread is closed to new comments.