Anonymous User 11187416
(@anonymized-11187416)
You could use a jQuery listener instead?
jQuery("#formId").submit(){
_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);
}
or something along those lines anyway.
do i need to integrate a js-file for the listener? or can i use it just as you mentioned it above?
Anonymous User 11187416
(@anonymized-11187416)
Depending your WordPress set up, you should have jQuery already installed. The only thing you’ll need to find is the ID in the <form> tag.
If you only have a class then you’ll need to modify the code to
jQuery(".class-name").submit(){
_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);
}
replacing class-name with the ACTUAL class, but keep in the dot.
Dear Martin, I will try it – thank you.
Dear Martin, my class’ name is:
wpcf7-form-control wpcf7-submit
Is it ok to have a blank in the
jQuery(“.wpcf7-form-control wpcf7-submit”).submit(){
_gaq.push([‘_trackEvent’, ‘Contact Form’, ‘Submit’]);
}
Anonymous User 11187416
(@anonymized-11187416)
No, you can’t have spaces and because that’s a button you’ll need a slight change
jQuery(".wpcf7-form-control.wpcf7-submit").click(){
_gaq.push(['_trackEvent', 'Contact Form', 'Submit']);
}
(when using multiple classes you replace the space with a full stop/dot).
Hi
I had the same problem. I was wondering where this jQuery listener should go?
Also I have 3 forms with different names all with the same class name ‘wpcf7-form-control wpcf7-submit’
So I take it I simply change it to:
jQuery(“.wpcf7-form-control.wpcf7-submit”).click(){
_gaq.push([‘_trackEvent’, ‘Contact Form 1‘, ‘Submit’]);
}
jQuery(“.wpcf7-form-control.wpcf7-submit”).click(){
_gaq.push([‘_trackEvent’, ‘Contact Form 2‘, ‘Submit’]);
}
Many thanks in advance!
Anonymous User 11187416
(@anonymized-11187416)
Heya,
There’s no particularly ‘right’ place to put it – just after the submit button. So I usually put my listeners just before the </body> tag.
Of course you’ll need to wrap this in <script> </script> tags.
If it isn’t working have a look at the developer error console, that should give you any JavaScript errors you’re having.
Hope this helps,
Martin