-
AuthorPosts
-
August 1, 2020 at 4:48 pm #1234515
Hi guys.
I’m happy to use Enfold theme! Can you help me, please?I have three Contact Forms on my landing page and I want to track them by three different event category with Google Analytics.
“NativeForm1_Sent” for first Contact Form
“NativeForm2_Sent” for second Contact Form
“NativeForm3_Sent” for third Contact FormIs it possible?
I’ve found a similar topic here: https://kriesi.at/support/topic/contact-form-tracking-with-ga/
But I’m not a coder :(( So I can’t adapt that code to solve my problem
I’ll be happy if you could help me.Thank you
MichaelAugust 5, 2020 at 12:24 pm #1235386Oops
4 days no answers :((
May be the question is too complicated?Support is still needed
MichaelAugust 6, 2020 at 4:56 am #1235575Hi,
Sorry for the delay. We can use the $formID parameter in the filter to check for the ID of the current contact form and apply the appropriate tracker.
Example:
add_filter('avf_contact_form_submit_button_attr','avia_add_submit_attributes_to_cf', 10, 3); function avia_add_submit_attributes_to_cf($att, $formID, $form_params){ if($formID == 1) { $att = "onclick=\"_gaq.push(['_trackEvent','Contact Form Send','Click/Touch','Footer']);""; } if($formID == 2) { $att = "onclick=\"_gaq.push(['_trackEvent','Another Event','Click/Touch','Footer']);""; } return $att; }
We can also use switch instead of the if statement: https://www.w3schools.com/php/php_switch.asp
switch ($formID) { case 1: code to be executed if $formID=1; break; case 2: code to be executed if $formID=2; break; case 3: code to be executed if $formID=3; break; ... default: code to be executed if n is different from all labels; }
Unfortunately, adding Google trackers or implementing advanced analytics across the site is out of the scope of support, so you may need to hire a freelance developer or contact our partner Codeable.
// https://kriesi.at/contact/customization
Best regards,
IsmaelAugust 6, 2020 at 5:23 pm #1235804Thank you, Ismael!
August 7, 2020 at 3:24 am #1235889Hi,
Did you need additional help with this topic or shall we close?
Best regards,
Jordan Shannon -
AuthorPosts
- You must be logged in to reply to this topic.