title: How to insert data on Google Tag Manager's dataLayer using wpForms wpforms_process_complete on Wordpress
body: <p>I want to push an event to Google Tag Manager's dataLayer when the user submitted the form successfully using wpForms plugin. I tried using the wpForms hook "wpforms_process_complete" and it seems that it's not working.</p>
  
  <p>Sample code in functions.php:</p>
  
  <pre><code>function wpf_process_completed( $fields, $entry, $form_id, $form_data ) {
    if ($form_data['id'] === 1033) {
          ?&gt;
              &lt;script&gt;
                  window.dataLayer = window.dataLayer || [];
                  window.dataLayer.push({ event: 'wpFormsSubmitted' });
              &lt;/script&gt;
          &lt;?php
      }
  }
  
  add_action('wpforms_process_complete', 'wpf_process_completed', 10, 4);
  </code></pre>
  
  <p>But nothing happens.</p>
  
  <p>I also tried printing a string and resulted an error.</p>
  
  <pre><code>function wpf_process_completed( $fields, $entry, $form_id, $form_data ) {
    echo 'submitted';
  }
  
  Error:
  WPForms AJAX submit error:
  SyntaxError: Unexpected token s in JSON at position 0
  </code></pre>
  
  <p>I don't know how to make it work. Please help!</p>