title: Add Google Analytics event to form submission in PHP
body: <p>I am looking to add an event to successful submissions of a form in PHP (a purchased script). I found the function in PHP that triggers on success and I marked where I think the analytics goes...</p>
  
  <pre><code>function emailSuccessfullySent() {
  global $translations, $lang, $options, $fdata, $is_ajax;
  
  // redirect to custom "success" page if it's been set
  if ( !empty($options['redirect_url'])) {
      if (!$is_ajax) {
          header('Location: '.$options['redirect_url']);
      } else {
          echo json_encode(array('redirect' =&gt; array($options['redirect_url'])));
      }
      exit;
  }
  
  // if no redirect has been set, echo out the success message
  if ($is_ajax) {
      echo json_encode(array('success' =&gt; array($translations-&gt;form-&gt;success-&gt;title-&gt;$lang)));
      // analytics code here
  } else {
      echo '&lt;h2&gt;'.$translations-&gt;form-&gt;success-&gt;title-&gt;$lang.'&lt;/h2&gt;';
      // analytics code here
  }
  
  removeUploadsFromServer();
  }
  </code></pre>
  
  <p>...however I am not sure how to fire the event JS:</p>
  
  <pre><code>ga('send', 'event', 'Form Button', 'submit', 'Feedback');
  </code></pre>