E
E
EarthFM2014-12-18 19:32:37
JavaScript
EarthFM, 2014-12-18 19:32:37

How to use google adwords in contact form 7?

Hi all. I installed the contact form 7 plugin on the site, and I want a conversion to occur when submitting the form (i.e. tracked in google adwords).
In the internet, I searched everywhere, it is shown that you need to create a thank you page. But I don’t need it like that, if we have ajax, I don’t see the point of creating a page)
How do I do it.
I created a function and put the google adwords code in there, now I need to display it, but where

?

$.wpcf7AjaxSuccess = function(data, status, xhr, $form) {
    if (! $.isPlainObject(data) || $.isEmptyObject(data))
      return;
    
    var $responseOutput = $form.find('div.wpcf7-response-output');
  
    $form.wpcf7ClearResponseOutput();

    $form.find('.wpcf7-form-control').removeClass('wpcf7-not-valid');
    $form.removeClass('invalid spam sent failed');

    if (data.captcha)
      $form.wpcf7RefillCaptcha(data.captcha);

    if (data.quiz)
      $form.wpcf7RefillQuiz(data.quiz);

    if (data.invalids) {
      $.each(data.invalids, function(i, n) {
        $form.find(n.into).wpcf7NotValidTip(n.message);
        $form.find(n.into).find('.wpcf7-form-control').addClass('wpcf7-not-valid');
        $form.find(n.into).find('[aria-invalid]').attr('aria-invalid', 'true');
      });

      $responseOutput.addClass('wpcf7-validation-errors');
      $form.addClass('invalid');

      $(data.into).trigger('invalid.wpcf7');

    } else if (1 == data.spam) {
      $responseOutput.addClass('wpcf7-spam-blocked');
      $form.addClass('spam');

      $(data.into).trigger('spam.wpcf7');

    } else if (1 == data.mailSent) {
      $responseOutput.addClass('wpcf7-mail-sent-ok');
      $form.addClass('sent');

      if (data.onSentOk)
        $.each(data.onSentOk, function(i, n) { eval(n) });

      $(data.into).trigger('mailsent.wpcf7');

    } else {
      $responseOutput.addClass('wpcf7-mail-sent-ng');
      $form.addClass('failed');

      $(data.into).trigger('mailfailed.wpcf7');
    }

    if (data.onSubmit)
      $.each(data.onSubmit, function(i, n) { eval(n) });

    $(data.into).trigger('submit.wpcf7');

    if (1 == data.mailSent)
      $form.resetForm();

    $form.find('[placeholder].placeheld').each(function(i, n) {
      $(n).val($(n).attr('placeholder'));
    });

    $responseOutput.append(data.message).slideDown('fast');
    $responseOutput.attr('role', 'alert');

    $.wpcf7UpdateScreenReaderResponse($form, data);
    
  }

Answer the question

In order to leave comments, you need to log in

1 answer(s)
M
Michael M, 2015-01-30
@EarthFM

Hey! It can be solved by a workaround. Sign up for a Google Analytics account if you don't already have one. Set up a simple event for successful form submission (manual - https://developers.google.com/analytics/devguides/... ). There will be something like ga('send', 'event', 'contactform', 'ok');
Then, in GA, set up an "event" type goal (manual - https://support.google.com/analytics/answer/1032415 ) with the event that we created in the first step. Achieving this goal will be the conversion.
Next, import this goal into AdWords (manual - https://support.google.com/adwords/answer/2375435 )
To do this, you will need to link your AdWords and Analytics accounts .
Everything is ready.
And AdWords conversions are an inconvenient and rarely used thing.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question