Tagged: google analytics, onclick
-
AuthorPosts
-
October 2, 2014 at 7:53 pm #329180
Hi, I need to add an “onclick event” different from each button of my different plans in my web.
I also need to track the contact form.
And finally I would like to know if I can add a track event in my anchors
If you could answer me in Spanish I would appreciate it very much.
greetings- This topic was modified 10 years, 2 months ago by jmguridi.
October 4, 2014 at 5:33 am #330103Hey jmguridi!
Thank you for using Enfold.
Please refer to this link: https://kriesi.at/support/topic/how-to-add-google-analytics-event-tracking-code-to-image-links-and-text-links/
Use different Custom CSS class for different buttons.
Cheers!
IsmaelOctober 7, 2014 at 7:11 pm #331849Hi Ismael,
Sorry, but I try hard and do not achieve that this works.
I put in functions.php the “ga-track” code exactly in the way you indicate and modified like that:function add_custom_script(){
?>
<script>
jQuery(window).load(function(){
jQuery(“.ga-track a”).attr(“onclick”,”_gaq.push([‘_trackEvent’, ‘Clics’, ‘BtnPlanBase’, ‘/Consulta_Plan_Base.html’]”);
});
</script>
<?php
}
add_action(‘wp_footer’, ‘add_custom_script’);I define a custom CSS class on my button with name “BtnPlanBase”
And last I define the event in google analytics. Try this in a basic html page, without enfold and track very well.October 9, 2014 at 7:15 am #332981Hey!
It would appear that you are not using the correct css class in your function.
.ga-track a
is simply guideline of the DOM element receiving the click event. Try replacing it with.BtnPlanBase
Alternatively, could you please forward us administrative FTP and WordPress credentials to your site for us to have a closer look.
Please check the “Set as private reply (Only you and moderators will see the content of this post)” option before posting any sensitive information.
Cheers!
ArvishOctober 9, 2014 at 2:54 pm #333249This reply has been marked as private.October 10, 2014 at 6:41 am #333680Hey!
Thank you for the login info but I get a Forbidden error when I access the page. Please check.
Best regards,
IsmaelOctober 10, 2014 at 6:43 pm #334032just prove those access and work fine.
October 11, 2014 at 10:04 am #334237Hi!
I get a forbidden error. I’ll ask the rest of the support team to take a look.
Regards,
IsmaelOctober 11, 2014 at 9:12 pm #334393Hi!
Same issue here. 403 forbidden error.
Could you check and let us know.
Cheers!
ArvishOctober 13, 2014 at 6:51 pm #335113This reply has been marked as private.October 14, 2014 at 5:36 am #335355Hi!
I’d suggest using Universal Analytics instead, you can make use of the already defined classes in your different buttons for this, basically you’d just need to include the following custom JS (either via wp_footer insertion or even in the Enfold Google Analytics field):
<script> (function($){ $(window).load(function() { $('.button-1 a').on('click', function() { ga('send', 'event', 'button', 'click', 'button-1'); }); $('.button-2 a').on('click', function() { ga('send', 'event', 'button', 'click', 'button-2'); }); $('.button-3 a').on('click', function() { ga('send', 'event', 'button', 'click', 'button-3'); }); }); })(jQuery); </script>
Reference:
https://developers.google.com/analytics/devguides/collection/analyticsjs/events
Cheers!
JosueOctober 16, 2014 at 1:14 am #336481Thanks a lot Josue! It’s working very well!
Regards!October 16, 2014 at 2:01 am #336487You are welcome, glad to help :)
Regards,
Josue -
AuthorPosts
- The topic ‘Tracking code on specific button’ is closed to new replies.