I am needing to track a click on a link in Google Analytics so I am adding the below to the footer of my Magento 2.3 website. I have jquery on the site but for some reason the below cost is not working. I don't see the click in GA nor do I see my message in the console. I am not sure what I am doing incorrect.
require(['jquery'],function($){
$(document).ready(function(){
$(".ink-refilling-suggestion").click(function(){
ga(‘send’, ‘event’, ‘ Refill Finder’, ‘Click’, 'Refill Finder View');
console.log('count refill finder click');
})
});
});
asked Aug 18, 2021 at 0:40
Jayreis
7452 gold badges31 silver badges77 bronze badges
-
Does console log print or not?Dhiren Vasoya– Dhiren Vasoya2021年08月18日 10:44:18 +00:00Commented Aug 18, 2021 at 10:44
1 Answer 1
check below code
require([
'jquery'
], function ($) {
'use strict';
$(document).ready(function () {
$(document).on('click', 'ink-refilling-suggestion', function() {
console.log('here');
});
});
});
answered Aug 18, 2021 at 10:56
Devidas
3,3731 gold badge30 silver badges68 bronze badges
default