Tracking Checkbox Selections within Adobe Analytics

Recently, I was asked to send an Adobe Analytics event when a user selected a checkbox so that business could know how often users opted in vs opted out to a piece of site functionality. This blog post will show you how you can leverage jQuery to listen for that specific checkbox selection and then pass over to Adobe Analytics the necessary tracking parameters.

Below is the logic you will need to track the specific checkbox being selected. I have written into the code a comment where you will need to modify for your specific name but outside of that, it should be a copy and paste job to get this to work

$(document).ready(function(){
$(‘input[type=”checkbox”]’).click(function(){
if($(‘#userdata-uuid-adduser-isonline’).is(“:checked”)){ //replace with div ID used to differentiate the checkbox. Just replace the userdata… with your ID leaving the hash symbol in front of it.

//Pass to Adobe Analytics
s.linkTrackVars = “events”;
s.linkTrackEvents = “event189”;
s.events = “event189”;
s.tl(this,’o’,’Authorized User Permission Selected’);

}
});
});

That’s it! Since I only needed this for an event, I just passed that in. But you can update this to pass in something to a prop/eVar if desired.