Hi

I've looked around at how people have managed to get something like this onclick="_gaq.push(['_trackEvent', 'Contact us', 'Click', 'Phone'])" added to their contact-us form (D7), but at first glance it all seems a bit complicated.

So I had the idea: can't I just add onload="_gaq.push(['_trackEvent', 'Contact us', 'Click', 'Phone'])" to the confirmation text when the form's been sent?

I thought that was accessible to me in setup but I can't find it so I guess I'm back to making a copy of the tpl in my theme and amending that.

Do you think that would work?

I'm not good at the following: which file do I need to amend, and will me amending the text with my onload JS actually fire off the JS or will Drupal stop it and if so, is there a way to make it not.

Cheers
J

Comments

JAScarb’s picture

Any thoughts?

JAScarb’s picture

OK, so if I change modules/contact.pages.inc I can get a Javascript alert to fire up if I put script into the "your message has been sent" message.

Moving contact.pages.inc to my theme, however, doesn't seem to work so I guess that only works for tpls

So next up it's looking like I'm going to have to work through this lot https://www.drupal.org/node/2183109 and learn about hooks and so on, which is probably no bad thing.

Stop me if you see me going off in the wrong direction.

Cheers
J

Sam Moore’s picture

Perhaps I've missed something, but - why not just send the user to a Thank You page after submission, and set that page as a conversion goal?

JAScarb’s picture

Cheers Sam

Yes, good thinking. It doesn't look like standard form will do that but webform does so I guess I'm heading off in that direction.

All the best
J

Sam Moore’s picture

It would be great if you posted a follow up to let everyone know how it worked out for you. I'm sure others would benefit.
Cheers

JAScarb’s picture

I do try / make an effort to do that :-)

JAScarb’s picture

Just a note, I quite like the standard contact form's ability to send the email to different people depending on a dropbox, so general enquiries go to sales, website problems go to the webdev. I can't seem to replicate this in WebForm although I'm bound to be wrong about that.

DrupalDope’s picture

that seems like a good idea, however, how to prevent users to access the thank you page directly and trigger false goals?