I have a contact form on the website. I want to add a conversion-tracking JS Code to it for SEO, so that every time someone submits a contact-form the code is called.
Including JS in silverstripe works either via the controller or via the template. But with that i would call the script on pageload and not after successful submission of the contact-form. So if a visitor navigates to the site, the conversion tracking will count +1 user, even though he did not use the contact form but called the phone number instead.
What i have tried so far:
I have tried to add the script into the ReceivedFormSubmission.ss, which i assumed to be used to display the after submission message.
So my ReceivedFormSubmission.ss file looks like this:
The content of conversiontracking.js is
(Sorry for the xxx-es but there is some user specific content in there.
How or where do i best add the conversion-tracking to make it a) work and b) only be called on successful submission of the contact form?
If the website i am referring to is needed, i will send the link via private message to prevent spam.
Screenshots of the userforms backend and the site i would like the conversion tracking to appear.
Thanks in advance for any helping comment!