Hello All,
i am currently using Google Analytics to collects stats about my site ( my site is created in ASP.NET 2.0 and C#).
i have asp:imagebutton called "Confirm Order". i want to track the clicking of this button.
the code for this button is as follows:
void ibConfirm_Click( object sender, ImageClickEventArgs e )
{
try
{
if ( Cart.Order.Items.Length == 0 )
{
Mysite.ClearBasket( );
Response.Redirect( string.Concat(
ConfigurationManager.AppSettings[ "HTTPDirectory" ],
"cart.aspx?sto=true" ) );
}
Cart.Order.Purchase( );
sendConfirmationEmail( Cart.Order );
Mysite.ClearBasket();
Server.Transfer("thanks.aspx", false);
}
catch (Exception ex)
{
this.HandlePageError(ex);
}
}
my question how can i add the GA tracking script to this button click in the code behind.
my GA tracking Script is like below:
<script type="text/javascript">
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
</script>
<script type="text/javascript">
try{
var pageTracker = _gat._getTracker("UA-xxxxxx-x");
pageTracker._trackPageview();
pageTracker._trackEvent('confirmOrder', 'Submit');
} catch(err) {}</script>
Thanks and i really appreciate any help.
I want to know how i can add this script to the onclick code above to so i can track the button clicks.
Thanks