Welcome to WebmasterWorld Guest from 54.196.238.210

Forum Moderators: open

Message Too Old, No Replies

Assign input variable to onclick event

     

AnonyMouse

10:20 am on Jun 28, 2008 (gmt 0)

10+ Year Member



Hi,

I have a search box that has a single input field and a submit button. When the submit button is pressed, an onClick event calls Google's urchinTracker.

I'd like to append whatever variable is put in the search box, to the onClick event so I can see it in Google Analytics:

<input name="searchterm" type="text">
<input type="submit" name="Submit" value="Submit" onClick=\"javascript:urchinTracker ('/siteSearch_SEARCHTERM_GOES_HERE'); >

Is this possible using JavaScript? Thanks in advance for any replies.

rocknbil

4:48 pm on Jun 28, 2008 (gmt 0)

WebmasterWorld Senior Member rocknbil is a WebmasterWorld Top Contributor of All Time 10+ Year Member



I'd like to append whatever variable is put in the search box, to the onClick event so I can see it in Google Analytics:

Can't you just put the tracker on the search results page? I don't know that you can do this with the urchin, you might get some assistance from the analytics help files.

AnonyMouse

6:30 pm on Jun 28, 2008 (gmt 0)

10+ Year Member



Thanks for the reply - unfortunately I can't put the tracker on the results page, I have to catch the variable straight from the search form :-(

daveVk

1:14 am on Jun 29, 2008 (gmt 0)

WebmasterWorld Senior Member 5+ Year Member



Maybe

<input name="searchterm" id="searchBox" type="text">
<input type="submit" name="Submit" value="Submit" onClick="urchinTracker ('/siteSearch_' + document.getElementById( 'searchBox' ).value );" >

AnonyMouse

5:58 pm on Jun 29, 2008 (gmt 0)

10+ Year Member



Certainly looks about right - I've added it to the form code, now have to wait until it shows up in the Analytics report. Many thanks!

AnonyMouse

12:42 pm on Jun 30, 2008 (gmt 0)

10+ Year Member



Just to confirm that that did the trick, many thanks!
 

Featured Threads

Hot Threads This Week

Hot Threads This Month