I have a short application form, where I capture some information, then redirect the user to a third party website where they complete the application.
I am using Google Analytics (and a Google conversion tracker) to monitor the hits on our site. Therefore I have to direct to a “conversion page” with the Analytics Javascript and a redirect. Unfortunately my javascript is not getting called.
How would I ensure the Javascript is called before the redirect happens?
<head runat="server">
<title></title></head><body>
<script type="text/javascript" src="/scripts/Analytics.js"></script>
<script type="text/javascript" src="/scripts/Analytics2.js"></script>
<!-- Google Code for Filling out Form Conversion Page -->
<script type="text/javascript">
/* <![CDATA[ */
var google_conversion_id = 964293672;
var google_conversion_language = "en";
var google_conversion_format = "2";
var google_conversion_color = "ffffff";
var google_conversion_label = "H0y7CMi73wIQqOjnywM"; var google_conversion_value = 0;
/* ]]> */
</script>
<script type="text/javascript" src="http://www.googleadservices.com/pagead/conversion.js">
</script>
<noscript>
<div style="display: inline;">
<img height="1" width="1" style="border-style: none;" alt="" src="http://www.googleadservices.com/pagead/conversion/964293672/?label=H0y7CMi73wIQqOjnywM&guid=ON&script=0" />
</div>
</noscript>
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
Page.LoadComplete += new EventHandler(Page_LoadComplete);
}
}
void Page_LoadComplete(object sender, EventArgs e)
{
Response.Redirect("https://anotherwebsite.com/c/transint?uri_b=ia_86894");
}
I have a third tracking script I need to add so I just used a JavaScript redirect in a jQuery docReady function.
I used window.location.replace(…), as it doesn’t put the redirect page in browsing history.
Thanks for your input @Aristos.