How do I add Google Analytics event tracking code to Image Hyperlinks and Text Hyperlinks in the Advanced Layout Editor.
I think I know how to do it in an HTML editor but is it possible to add the tracking code in the Advanced Layout Editor?
So to be clear, I am using the Advanced Layout Editor to create my website. I have added an image to a page in a “Media Element”. I have added an “Image Link” to an affiliate program. I want to add the event code to that link so I can track the clicks.
I understand that this is what the code looks like:
I just found this plugin, https://yoast.com/wordpress/plugins/google-analytics/#utm_source=wordpress&utm_medium=plugin&utm_campaign=wpgaplugin&utm_content=v504
Hi!
Thank you for using Enfold.
Are you using the Image element when adding the images? You can add google analytics tracking code on an onclick attribute. First, you need to add a unique selector to the image element. Refer to this link for more info:
http://kriesi.at/documentation/enfold/turn-on-custom-css-field-for-all-alb-elements/
Use “ga-track” for example. Add this on functions.php to apply the onclick attribute on the link:
function add_custom_script(){
?>
<script>
jQuery(window).load(function(){
jQuery(".ga-track a").attr("onclick","_gaq.push(['_trackEvent', 'Videos', 'Play', 'Baby\'s First Birthday']");
});
</script>
<?php
}
add_action('wp_footer', 'add_custom_script');
Modify the tracking event code: https://developers.google.com/analytics/devguides/collection/gajs/eventTrackerGuide#SettingUpEventTracking
Best regards,
Ismael
Thank you for your help.