Tagged: Analytics, button, class, CONTACT FORM, CSS, event tracking
-
AuthorPosts
-
September 15, 2015 at 3:47 pm #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!
September 15, 2015 at 4:27 pm #503457PS. 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, 1 month ago by emeraldwave. Reason: replaced domain name with mydomain
September 15, 2015 at 11:51 pm #503766Hi,
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 -
AuthorPosts
- You must be logged in to reply to this topic.