AdWords
2.8K members online now
2.8K 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

Conversion Tracking Code where to post in PHP page

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

I've a "booking_form" webpage in php which occurs when "Send Query" button get pressed from "contact.html" webpage. I want to put the Adwords conversion tracking code in "booking_form.php" but the problem is that my booking_form webpage doesn't have <body> tag, so where I post Conversion Tracking Code in that file. Please suggest me. Thanks for the support.

 

Coding part of my booking_form.php -

<?php

if(isset($_POST['submit']))

{

 

$to = " myemail@gmail.com";

 

$subject = "simpex healthcare Contact Us form";

 

$message = "Hi,<br>Sir/Madam";

 

$message .= "<br>Greetings";

 

$message .= "<br><br>

 

<table width='300' cellspacing='0' cellpadding='4' border='1'>

 

<tbody>

 

<tr>

 

<td align='right'> Name :</td>

 

<td>".$_REQUEST["name"]."</td>

 

</tr>

 

<tr>

 

<td align='right'> Email Id :- </td>

 

<td>".$_REQUEST["email"]."</td>

 

</tr>

 

<tr>

 

<td align='right'> Mobile :- </td>

 

<td>".$_REQUEST["mobile"]."</td>

 

</tr>

<tr>

 

<td align='right'> Subject :- </td>

 

<td>".$_REQUEST["message"]."</td>

 

</tr>

</tbody>

 

</table>";

 

$header = "MIME-Version: 1.0\r\n";

 

$header .= "Content-type: text/html\r\n";

 

$retval = mail ($to,$subject,$message,$header);

 

if( $retval == true )

 

{

 

?>

 

<script language="javascript">

 

alert("Thank You! We will contact you shortly.");

 

window.location.href="<?php echo $_SERVER['HTTP_REFERER'];?>";

 

</script>

 

<?php

 

}

 

else

 

{

 

?>

 

<script language="javascript">

 

alert("Sorry! Form Not Submited.");

 

window.location.href="<?php echo $_SERVER['HTTP_REFERER'];?>";

 

</script>

 

<?php

 

}

 

}

 

?>

 

2 Expert replyverified_user

Re: Conversion Tracking Code where to post in PHP page

[ Edited ]
Top Contributor
# 2
Top Contributor

Hi Aura F,

 

Welcome to AdWords Community.

 

In order to be able to use Conversion Tacking Code, you will need to have a separate 'thank-you' page. This 'thank-you' page will be visible only when the form is submitted successfully. The conversion code will be used on this page only. 

 

In your present form page, it does not redirect to 'thank-you' page after successful submission, rather it pops up a Javascript based message 'Thank You! We will contact you shortly'.

 

You can ask your developer to do this required setup for you.

 

Hope it helps.

 

Thanks
Ratan

Join me on Google+


About Me: Community Profile | Ratan Jha INC.
If this or any other post solved your question, do not hesitate to accept it as the solution.

Re: Conversion Tracking Code where to post in PHP page

Top Contributor
# 3
Top Contributor
Hi Aura F,

The AdWords conversion code can go anywhere between the body tags. In your script above, include the AdWords code in the block you return on successful submission of the form. You say this is the coding part of the page, so I am assuming there is more to the page than this, and this is not a callback or AJAX page.

If this were callback or AJAX content, the javascript alert function wouldn't work either.

What it looks like is happening here is you are returning a page that has the javascript alert() function, then a redirect to the original page, and not other html or javascript. This means the AdWords conversion code will need to run before the user clicks on the "OK" button of the alert dialog. That won't always be the case. For this reason, I agree with Ratan J, you're better off with a dedicated thank you page. I don't see the point of returning the visitor to your contact form page.

Best of Luck!

Pete
petebardo -- Deadhead doing AdWords

Re: Conversion Tracking Code where to post in PHP page

Visitor ✭ ✭ ✭
# 4
Visitor ✭ ✭ ✭
Thanks Ratan and petebardo,

Please go through my website www.aurafountains.com and suggest me a direction to put my Adwords tracking code in "booking_form.php", if this page is not suitable then please tell me how can I customize it so that I can put my Tracking Code into it.

Thanks a lot for you kind support..

Re: Conversion Tracking Code where to post in PHP page

[ Edited ]
Top Contributor
# 5
Top Contributor

Hi Aura F,

 

On your existing setup, you should create a separate page that you will use as 'thank-you' page. A confirmation page that will be visible when the form is submitted successfully.

 

Once you have created this page, replace the code in your booking-form page as below-

 

Replace the following -

<script language="javascript">

alert("Thank You! We will contact you shortly.");

window.location.href="<?php echo $_SERVER['HTTP_REFERER'];?>";

 </script>

 

with -

 

<script language="javascript">

window.location.href="http://youwebsite.com/yourthankyoupageurl";

</script>

 

About AdWords conversion code, paste it in your 'thank-you' page.

 

I haven't tested it obviously, but it should work.

 

Thanks
Ratan

Join me on Google+


About Me: Community Profile | Ratan Jha INC.
If this or any other post solved your question, do not hesitate to accept it as the solution.

Re: Conversion Tracking Code where to post in PHP page

Visitor ✭ ✭ ✭
# 6
Visitor ✭ ✭ ✭
Thanks Ratan,
I'll apply the changes and let you know the status by tomorrow.