Tagged: Google Analytics event tracking
I use a text block element with text and an external link like so:
<a href="http://www.example.com/test.html">Site Name</a>.
I then switch to “Text” mode and add the google event tracking like so:
<a href="http://www.example.com/test.html" onclick=ga('send', 'event', 'News', 'Click', 'Test');>Site Name</a>.
Save and this works, verified in google analytics but the entire “onclick” disappears if you reload the page or switch to “Visual” mode. Any suggestions? How would this work with a button element? Thanks
Michael
Hey!
It is recommended to use a Code Block for this cases, that will prevent custom code from being stripped by WordPress.
Cheers!
Josue
I’m referring to this Code Block:
Cheers!
Josue
Josue,
Thanks, that worked!
You are welcome, glad we could help :)
Regards,
Josue