Monday, June 3, 2024
 Popular · Latest · Hot · Upcoming
140
rated 0 times [  141] [ 1]  / answers: 1 / hits: 51443  / 13 Years ago, tue, july 5, 2011, 12:00:00

I have been going round and round trying to find a definitive answer. Basically, I want to add the Google Analytics event tracking to a form submit - I was hoping to add an onClick to it, but I am having a tough time finding out if all the browsers support it.



I asked the person who designed the form, and she said that the reason they didn't use the button type is that is caused issues submitting the form in some browsers, but could not remember which ones.



So, will it work across browsers, or should I switch to button?



Relevant code below:



<input name=submit id=submitme type=image 
src=/graphics/creative/landing_pages/popup/ibd_signmeupbtn.gif
alt=Sign Me Up!
onClick=_gaq.push(['_trackEvent', 'Registrations', 'Register', 'Lightbox']);
tabindex=8 />


EDIT I have _gaq defined. The real goal of this question is to make sure that using an onClick with an input image is OK to do.


More From » html

 Answers
8

Try wiring it up a little different



<input name=submit id=submitme type=image 
src=/graphics/creative/landing_pages/popup/ibd_signmeupbtn.gif
alt=Sign Me Up!
onclick=SignMeUp();
tabindex=8 />


And create your function like so:



<script type=text/javascript>
function SignMeUp()
{
if (!!_gaq) // make sure _gaq is defined
_gaq.push(['_trackEvent', 'Registrations', 'Register', 'Lightbox']);
}
</script>

[#91342] Monday, July 4, 2011, 13 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
hadens

Total Points: 142
Total Questions: 98
Total Answers: 100

Location: Kenya
Member since Mon, Jun 14, 2021
3 Years ago
hadens questions
;