If you are a Google Analytics user, you can now use conversion tracking through the Button Element to track when someone clicks on a button on your website. Read on…
Read More About The Button Element!Setting Up The ButtonThe first step to set up conversion tracking is to add a custom attribute to the Button Element when you add it to the page. Add this in the 『Button Additional Attributes Field』 (customizing it for your URL):
Copy to Clipboarddata-ga-url='https://example.com/your-link' 1data-ga-url='https://example.com/your-link'Add Script To Theme OptionsThe second step is to add this script to the Advanced > Code Fileds (Tracking etc.) > Space before Theme Options field:
Copy to Clipboard
jQuery( document ).ready( function() {
var $buttons = jQuery( '.fusion-button[data-ga-url]' );
jQuery.each( $buttons, function( index, element ) {
jQuery( element ).attr( 'onclick', 'return gtag_report_conversion('' + jQuery( element ).data( 'ga-url' ) + '');' );
} );
} );
x 12 jQuery( document ).ready( function() {3 var $buttons = jQuery( '.fusion-button[data-ga-url]' );45 jQuery.each( $buttons, function( index, element ) {6 jQuery( element ).attr( 'onclick', 'return gtag_report_conversion('' + jQuery( element ).data( 'ga-url' ) + '');' );78 } );910 } );11That』s it! Your button is now set up to track conversions vis Google Analytics. For more general information on tracking clicks on your website as conversions see this Google article.