简体   繁体   中英

Count clicks (conversions) in Google Adwords

I have a contact form in a website and I want to count how many people have clicked in it and know whatever Google knows about them. That's what I want it to do:

  1. The button is clicked
  2. The fields are checked: they have to be not empty and filled with alphanumeric characters. The e-mail address is validated too.
  3. If everything goes ok, via AJAX I call a PHP script which sends an email to our marketing team.
  4. I show an alert to let the user know that everything went OK
  5. I count the conversion

I read Google's documentation to do so, and I have the following code in the end of the page:

<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 1234561234; // I've changed my ID for privacy reasons
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "AbCdEFGhijkLMnOPqRs"; // I've changed the label for privacy reasons
var google_remarketing_only = false;
/* ]]> */
</script>
<script type="text/javascript" src="//www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display:inline;">
<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/1234561234/?label=AbCdEFGhijkLMnOPqRs&amp;guid=ON&amp;script=0"/>
</div>
</noscript>

And I have the following code after the validation on my JS (when the ajax performs properly, it takes note of the conversion by executing goog_report_conversion(' https://www.homepage.com ');

if ($('.has-error').length == 0)
    {
        $.ajax({
            type: 'POST',
            url: $('#contact-form').attr('action'),
            data: formData
        })
        .done(function(response) {
            var objResponse = jQuery.parseJSON(response);
            if (objResponse.success){
                // Clear the form.
                $('#name').val('');
                $('#email').val('');
                $('#message').val('');
                alert('We'll contact you very soon! Thank you!');
                goog_report_conversion('https://www.homepage.com');
            }
            else
            {
                alert('Please send us an email to info@homepage.com as we're experiencing some troubles in our server.');
            }
        })
        .fail(function(data) {
            alert('Please try again later');
        });
    }

I have also the Tag Assistant extension on Chrome. Everytime I enter the website I can see the Analytics tag to know who's entering AND the conversion code, so I think it's not installed in the correct place:

标签助手

We setted up this situation a few days ago and we're already counting, but we count more clicks than emails received (and we're logging those emails, so we know how many they send). I think I'm missing something but I don't know what is or where to track the error. Can you help me, please?

Thank you all, buddies :)

Ok, I don't know why is your conversion code wrong installed, but this is what I'l would do ( if the alert is html not js alert ):

In the alert, the HTML code alert, paste this code:

<img height="1" width="1" style="border-style:none;" alt="" src="//www.googleadservices.com/pagead/conversion/1234561234/?label=AbCdEFGhijkLMnOPqRs&amp;guid=ON&amp;script=0"/>

This is the "noscript" part of your conversion code.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM