Viewing 3 posts - 1 through 3 (of 3 total)
  • Author
    Posts
  • #503420

    Hi,
    I’ve 2 contact forms and would like to install Google’s Event Conversion Tracking when either form is submitted (without validation errors).

    So I searched the forum and have installed your sample code shown here: https://kriesi.at/support/topic/please-clear-this-up-for-em-ga-tracking-2/#post-349646 in child functions.php.

    However I still don’t see where I can add the correct CSS class onto the contact form ‘button’ via Avia Layout Builder – How can I do that?

    Thanks!

    #503457

    PS. I added access below.

    Also I now notice that adding the sample code above gives a parse error (and have temporarily disabled functions.php):

    PHP Parse error: syntax error, unexpected ‘$’, expecting ‘&’ or T_VARIABLE in C:\Inetpub\vhosts\mydomain.com\httpdocs\cms\wp-content\themes\enfold-child\functions.php on line 13.

    Here’s what’s in my functions file:

    <?php

    /*
    * Add your own functions here. You can also copy some of the theme functions into this file.
    * WordPress will use those functions instead of the original functions then.
    */

    /*
    * Enable onClick button event tracking for multiple forms if no error, by button’s class
    * See https://kriesi.at/support/topic/please-clear-this-up-for-em-ga-tracking-2/#post-349057
    */
    (function($){
    $(window).load(function() {
    $(‘.contact_form_1 input[type=”submit”]’).on(‘click’, function() {
    if (!$(‘.contact_form_1 p’).hasClass(‘error’)) {
    ga(‘send’, ‘event’, ‘Contact’, ‘Send Message’, ‘Contact form’);
    }
    });
    $(‘.contact_form_2 input[type=”submit”]’).on(‘click’, function() {
    if (!$(‘.contact_form_2 p’).hasClass(‘error’)) {
    ga(‘send’, ‘event’, ‘Contact’, ‘Get A Quote’, ‘Contact form’);
    }
    });
    });
    })(jQuery);

    • This reply was modified 9 years, 3 months ago by emeraldwave. Reason: replaced domain name with mydomain
    #503766

    Hi,

    Try dragging a Code Block and place the code there instead:

    (function($){
    	$(window).load(function() {
    		$('.contact_form_1 input[type="submit"]').on('click', function() {
    			if (!$('.contact_form_1 p').hasClass('error')) {
    				ga('send', 'event', 'Contact', 'Send Message', 'Contact form');
    			}
    		});
    		$('.contact_form_2 input[type="submit"]').on('click', function() {
    			if (!$('.contact_form_2 p').hasClass('error')) {
    				ga('send', 'event', 'Contact', 'Get A Quote', 'Contact form');
    			}
    		});
    	});
    })(jQuery);

    Regards,
    Josue

Viewing 3 posts - 1 through 3 (of 3 total)
  • You must be logged in to reply to this topic.