AdWords
4.7K members online now
4.7K members online now
Use AdWords conversion tracking and reporting to measure your results. Have a question about Google Analytics? Post it here, on the Google Analytics Community!
Guide Me
star_border
Reply

Tracking conversion on Ajax

Rising Star
# 1
Rising Star

Hi Guys,

 

I am looking a way to place conversation tracking code and I've implemented it using a method I found on StackOverflow.

 

 

$('#contact_form').validate({
		submitHandler:function(form) {
			var querystring = $(form).serialize();
			$.ajax({
				type:'POST',
				url:$('#action').val(),
				data:querystring,
				success:function(data) {
					if(data == true) {
						$('#contact_form').hide();
						$('#contact_form_msg').show();
                        googleTrackingPixel();
					}
				}
			})
		}
	});

    function googleTrackingPixel() {
        // set google variables as globals
        window.google_conversion_id = 955074050
        window.google_conversion_language = "en"
        window.google_conversion_format = "2"
        window.google_conversion_color = "ffffff"
        window.google_conversion_label = "lpd7CO6XwQMQgoy1xwM"
        window.google_conversion_value = 0

        var oldDocWrite = document.write // save old doc write

        document.write = function(node){ // change doc write to be friendlier, temporary
            $("body").append(node)
        }

        $.getScript("http://www.googleadservices.com/pagead/conversion.js", function() {

            setTimeout(function() { // let the above script run, then replace doc.write
                document.write = oldDocWrite
            }, 100)

        })
    }

 Will this able to track my conversion? In here I don't have a seperate page as thank you, to insert the html code. Thank you page being excuted through AJAX

2 Expert replyverified_user
1 ACCEPTED SOLUTION

Accepted Solutions
Marked as Best Answer.
Solution
Accepted by topic author Nisal L
September 2015

Re: Tracking conversion on Ajax

Top Contributor
# 2
Top Contributor

Hi Nisal,

 

If you want to install the conversion tracking code for AJAX using Google Tag Manager, then this technical article by  theniks does it for you:-

 

https://www.en.adwords-community.com/t5/User-Articles/AdWords-Conversion-code-with-Google-Tag-manage...

 

Pankaj

View solution in original post

Marked as Best Answer.
Solution
Accepted by topic author Nisal L
September 2015

Re: Tracking conversion on Ajax

Top Contributor
# 2
Top Contributor

Hi Nisal,

 

If you want to install the conversion tracking code for AJAX using Google Tag Manager, then this technical article by  theniks does it for you:-

 

https://www.en.adwords-community.com/t5/User-Articles/AdWords-Conversion-code-with-Google-Tag-manage...

 

Pankaj

Re: Tracking conversion on Ajax

Rising Star
# 3
Rising Star
Thanks @pankaj1782 and @theniks

Re: Tracking conversion on Ajax

Top Contributor
# 4
Top Contributor