How to add Google tracking code to Contact form once submitted

‌ I've tried adding a Google tracking code in the 'done' function in file /templates/my-site-name/modules/contact_form/index.php to include Google Tracking using jquery by following a post here but it didn't seem to work. How can I instead prepare a new separate 'submitted' or 'thankyou' page where I can paste in the Google code as is, and redirect the contact page to the new page after submission?

So far I've added a new file /templates/my-site-name/modules/contact_form/submitted.php with the following code. How do I now redirect to this page after form submission? 

<?php include THIS_TEMPLATE_DIR. "header.php"; ?>

<div class="container">
  <div  class="edit" field="content" rel="content">
    <h2>Enquiry Submitted</h2>
    <div  class="edit" field="contact_form_submitted" rel="content">
      <module type="contact_form" class="contact-form" id="contact_form" />
    </div>
  </div>
</div>
<!-- Google Code for Contact Form Completed Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = xxxxxxxxxx;
var google_conversion_language = "en";
var google_conversion_format = "3";
var google_conversion_color = "ffffff";
var google_conversion_label = "xyz";
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/xxxxxxxxxx/?label=xyz&amp;guid=ON&amp;script=0"/>
</div>
</noscript>
<?php include THIS_TEMPLATE_DIR.  "footer.php"; ?>

Thanks,
Nick

You must be logged in to reply on this thread


Sign Up
nick