• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 733
  • Last Modified:

ASP.net VB AdRotator OnClick for Google Analytics

Please HELP!
I have an asp.net web form with 4 ad rotator controls.  There is no "on-click" event for the ad rotator.  

I need to integrate google analytics event tracking in order to track the click.  The google event tracking requires the on-click event to call a small javascript that records the oubount link.

I was thinking that I coud use an AdRedirect.aspx page that would call the javascript function from code behind with the required parameters and then redirec the user to the url.    I'm not sure how to call a javascript function from code behind.  I know it can be done, but I'm not sure how.

Has anyone done this?

Thanks in advance!
0
dtechfish
Asked:
dtechfish
1 Solution
 
rajeeshmcaCommented:
Hi dtechfish,

This is the function at html page:

<script language=”javascript”>
   function test()
   {
      //Add the function code here
   }
</script>

To call this javascript function from code behind (.vb), Use Page.RegisterStartupScript function like the code below:

Dim strScript As String = “<script language=javascript” id=’myClientScript’>test();</script>
Page.RegisterStartupScript(“callTest”,strScript)
0

Featured Post

Free Tool: Path Explorer

An intuitive utility to help find the CSS path to UI elements on a webpage. These paths are used frequently in a variety of front-end development and QA automation tasks.

One of a set of tools we're offering as a way of saying thank you for being a part of the community.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now