Viewing 5 posts - 1 through 5 (of 5 total)
  • Author
    Posts
  • #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 Form

    Is 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
    Michael

    #1235386

    Oops
    4 days no answers :((
    May be the question is too complicated?

    Support is still needed
    Michael

    #1235575

    Hi,

    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,
    Ismael

    #1235804

    Thank you, Ismael!

    #1235889

    Hi,

    Did you need additional help with this topic or shall we close?

    Best regards,
    Jordan Shannon

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