I recently added the Google Classroom share button to my website. I'm looking to fire off a Google Analytics event every time this share button is clicked. I've tried using a javascript onClick to do it, but that didn't work. I think it might be because this creates an iframe when rendered by the browser.
$('#___sharetoclassroom_0').on('click', function(e) {
ga('send', 'event', 'gClassroom', 'gClassroom Click', 'Google Classroom Clicked');
}
I then saw the "data-onsharestart" attribute I can add to the Google Classroom tag and tried using that. That didn't work either...
<g:sharetoclassroom url="URL" data-onsharestart="gClassroomCount" size="20"></g:sharetoclassroom>
function gClassroomCount() {
ga('send', 'event', 'gClassroom', 'gClassroom Click', 'Google Classroom Clicked');
}
Any ideas on how I could add this event to the Google Classroom Share button?