Rich-text Reply

Is This Possible... Track Clicks

joejob 09-01-16

Is This Possible... Track Clicks



Is it possible to track the number of times my users are clicking on various buttons on my site.


I want to track the clicks and not the url that the buttons link to... because some of these buttons don't have a url behind them, they simple load a pop up or some other UX.


Any advice on how to implent this for ALL pages and not a split version of a page would be greatly appreciated.

Level 2

CouchPsycho 09-04-16

Re: Is This Possible... Track Clicks


this is not possible within optimizely if you want to get an absolute value. If you just want to know, if someone clicked a button or not you can use specific click goals for each button or a group of buttons.

Another weired approach can be custom events for each absolute value ( "clicked once, twice,..."), count the number of clicks in a cookie and fire the custom events after increasing the click value. But, as mentioned, it is as weired as trying to do this via google analytics.

What is your idea behind the test, why is the absolute number of clicks interesting?

Kind regards


"the essence of the creative act is to see the familiar as strange." (anonymous)
joejob 09-05-16

Re: Is This Possible... Track Clicks

Anyone...? Thanks in advance.

Level 2
joejob 09-06-16

Re: Is This Possible... Track Clicks

Thank you for your reply.


I don't need to know the number of times each user clicks it... i just want to count the total number for all users.


Lets say i want to introduce a new feature called 'Print Page', i would like to be able to add a new 'Print Page' button to my site and then gauge how many people clicked this before i actually build the feature.


I don't want to split test this, i just want to roll this out to all users.

Level 2
robertchan 09-06-16

Re: Is This Possible... Track Clicks

Yes, this is possible.


In your case, you can create the element dynamically (check out the code from this post:, and append it to the same section of each page. Once you have the button(s) you want on every page, you can create a custom goal that pushes an event each time a visitor clicks on one of the buttons.


Let's say you want to track the clicks on the first instance of an element with a class of newElement, you would have something like this in your variation code:


var newElement = document.getElementsByClassName('newElement'[0]);

newElement.addEventListener('click', function(){
    window['optimizely'] = window['optimizely'] || [];
    window.optimizely.push(["trackEvent", "newElementClick"]); }

Next, you'll want to create this event as a goal in your experiment's goal section. Notice how the callback of the event listener pushes a new event into Optimizely which will populate with your results.

Robert Chan

Experimentation Hero
DanielQ 09-13-16

Re: Is This Possible... Track Clicks

Hello Joejob,

If you feel like your question was answered, would you mind accepting a response as a solution? This will help other folks who have a question similar to yours!

Thank you!
Daniel Quick, Optimizely