I'm trying to setup a link tracking on WordPress. There are several links to the same site, they all share the same class:
<a class="gaClickTrack" href="https://www.amazon.es/Heromask-HeroMask-Aprende-idiomas-jugando/dp/B06XWHZ5Q4" target="_blank" rel="noopener">Buy Now Securely On Amazon!</a>
<img class="gaClickTrack wp-image-3372 size-medium" src="https://www.edinventa.com/wp-content/uploads/2018/07/buy-now-300x207.png" alt="Buy Now" width="300" height="207" />
We are using the plugin "Per page head", which allows you to add content into the section for a specific page, like custom JS or custom HTML. This is the custom code added:
<script>
jQuery('.gaClickTrack').on('click', function() {
ga('send', 'event', 'button', 'click', 'amazon-button-clicked');
});
</script>
Note: if we use $
instead JQuery
, it doesn't seem to work: the console returns an error.
We are using the Chrome extension Google Analytics Debugger, but either we don't know how to use it or it detects nothing.
I can see on Google Analytics - Real time - General Vision
, that it detects there is someone on the page, but I don't see the click event anywhere (I guess it should appear on Real time - Events
.
Where is our mistake??
jQuery(document).ready(function(){ jQuery('.gaClickTrack')... });
(aka wrapping your current code in.ready()
)?Uncaught ReferenceError: ga is not defined
. How can I know if the functionga
actually exists or it's a code syntax problem? Thanks so much!WooCommerce Google Analytics Pro plugin
. Support just answered they don't support Google Tag Manager yet. I'm trying to get a solution to use it together with that plugin anyway.