| Welcome to WebmasterWorld Guest from 22.214.171.124 |
register, free tools, login, search, subscribe, help, library, announcements, recent posts, open posts,
|Subscribe and Support WebmasterWorld|
|Assign input variable to onclick event|
| 10:20 am on Jun 28, 2008 (gmt 0)|
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">
| 4:48 pm on Jun 28, 2008 (gmt 0)|
|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.
| 6:30 pm on Jun 28, 2008 (gmt 0)|
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 :-(
| 1:14 am on Jun 29, 2008 (gmt 0)|
<input name="searchterm" id="searchBox" type="text">
<input type="submit" name="Submit" value="Submit" onClick="urchinTracker ('/siteSearch_' + document.getElementById( 'searchBox' ).value );" >
| 5:58 pm on Jun 29, 2008 (gmt 0)|
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!
| 12:42 pm on Jun 30, 2008 (gmt 0)|
Just to confirm that that did the trick, many thanks!
All trademarks and copyrights held by respective owners. Member comments are owned by the poster.
© Webmaster World 1996-2014 all rights reserved