Adding Tracking to Button

Hi there

I’ve been asked to add a Google tracking code to a submit form in my Foundry built site.

I’ve been given this -

onClick=“ga(‘send’, ‘event’, { eventCategory: ‘Contact Form’, eventAction: ‘Submit’, eventLabel: ‘Contact Page’});”

Any ideas on how to best add this? I tried with the following but it returned a fatal error - cannot redeclare PHPMailerAutoload()

Any ideas? Cheers

get rid of the curly quotes (paste it as plain text)
here did you put it?

Hi! - I added it like this…

I’m guessing something is bad in there!


Where and how did you add the code?

1 Like

depending on where/how you added it you may need <script></script> tags

Might have a look at this video:


Thanks - that deals with Google Analytics generally. My question is for adding tracking code to a specific form send button.

My Call to Action let’s you add events to all kinds of things including buttons and links.

Hi Joe. Can that be integrated into a form to act as a submit button?

Why don’t you just set up tracking on the Thank You page, simple method that triggers on load.

If you are using Foundry’s forms, I think the buttons are built into the form, but call to action does have an “external Trigger” that allows you to track a form submit. I just ran a quick test with foundry and in preview, it does trigger a “call to action”. In my test case, it just opened a “peek-a-boo”.

It does have Analytics tracking options:

Nice! I’ll give that a try. Cheers

Yes. CTA can trigger based on a form submit. Thanks @teefers

1 Like

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.