-
AuthorPosts
-
March 30, 2016 at 4:01 pm #605228
Hi,
I would like to include google analytics event tracking to my button created from the theme. Is there a way to add the neccesary code to it?
The link should be something like that:
<a href="http://www.fa.si/video/4B_SPLGIM_promo.mp4" onClick=”ga(‘send’, ‘event’, ‘TSM Downloads’, ‘download’, ‘Aftermovie’);”>TEST</a>
*The link is not realI hope I made my question clear as english is not my native language. Thank you for your help.
- This topic was modified 8 years, 8 months ago by fotoasja. Reason: corrected the code
March 30, 2016 at 4:43 pm #605274I also tried to put the code in the code box but it also does not work. Any advice?
March 30, 2016 at 4:45 pm #605277Hey!
Please turn on custom CSS field for ALB elements – http://kriesi.at/documentation/enfold/turn-on-custom-css-field-for-all-alb-elements/ and edit your button and give it a custom CSS class and then add following code to Functions.php file in Appearance > Editor
function my_custom_attr(){ ?> <script> jQuery(window).load(function(){ jQuery('.your-custom-class a').attr('onClick','YOUR CODE GOES HERE'); }); </script> <?php } add_action('wp_footer', 'my_custom_attr');
Best regards,
YigitMarch 30, 2016 at 5:17 pm #605299Thank you for a fast response. How about multiple buttons with different code? Do I add just another instance of the code you provided?
March 30, 2016 at 5:23 pm #605308Hi!
You can additional lines to the code as following
function my_custom_attr(){ ?> <script> jQuery(window).load(function(){ jQuery('.your-custom-class a').attr('onClick','YOUR CODE GOES HERE'); jQuery('.your-custom-class-two a').attr('onClick','YOUR CODE GOES HERE'); }); </script> <?php } add_action('wp_footer', 'my_custom_attr');
Regards,
YigitMarch 30, 2016 at 7:05 pm #605378I just can’t get it to work. Is my code ok?
function my_custom_attr(){ ?> <script> jQuery(window).load(function(){ jQuery('.video a').attr('onClick','ga(‘send’, ‘event’, ‘TSM downloads’, ‘download’, ‘promo’);'); jQuery('.videor a').attr('onClick','ga(‘send’, ‘event’, ‘TSM Downloads’, ‘download’, ‘reportaza’);'); }); </script> <?php } add_action('wp_footer', 'my_custom_attr');
Again, thank you for your help.
March 31, 2016 at 8:32 pm #606212Hey!
Try the following:
https://kriesi.at/support/topic/please-clear-this-up-for-em-ga-tracking-2/#post-348525Best regards,
Josue -
AuthorPosts
- You must be logged in to reply to this topic.