My organisation got accepted for the Google Ads Grant. There are several benefits that we can only unlock if we are able to set up conversion tracking. I am trying to get my head around how this would work with civicrm and have not had much luck with an online search.

I'm trying to understand how one would set up the tracking code on the thank you pages since civicrm's thank you pages are automatically and dynamically generated. I'm therefore not sure where one would place the conversion tracking code.

Has anyone here worked out how to achieve conversion tracking with Civicrm?

Ideally the solution would allow us to easily change the tracking code so we can have the conversion of the specific thank you pages match the specific ad. Is there a way to put the tracking code into the Introductory Text or the Footer Text of the Thank-you screen within civicrm events for example?

sorry for the many questions. Just slowly chipping away at features on our wishlist and coming across questions as we tackle them.

Thanks for help here, it has been really appreciated.

2 Answers 2


We are doing this exact thing at the moment. I was kindly given some code that sends events to GA and Facebook pixel on the Thank You page by @jtwyman on Mattermost. A Civi developer worked with us on it to build an extension - and evolved it slightly to respect DO NOT TRACK.

We haven't got it working 100% yet. We have an issue that completed donation £values are not being sent back to GA (membership values are being sent correctly). It's in our Github repo but private at the moment until the issue is fixed, but happy to make public and share when it's working correctly.

I'm not sure how others are handling this.

EDIT: After Googling, I found that Matt Wire released an extension at the same time we had ours developed:


I've raised an issue asking to have our Facebook Pixel and DNT features added so that we can just star using that rather than maintaing our own:


  • Thanks so much for the offer to make it public. That would be very much appreciated.
    – user7275
    Feb 1, 2020 at 21:44
  • Updated my answer to include edit and links.
    – sjparker
    Feb 4, 2020 at 8:09

It might not work in this case but in case someone is trying for a temporary fix:

Civicrm displays pages using templates. By identifying the template file you can create a file and directory structure that mimics the template used to display the part of civicrm original/path/OriginalTemplate.extra.tpl - but add .extra. into the filename. Civicrm will insert this into the page as per https://civicrm.org/blog/dave-greenberg/now-its-easier-add-custom-behaviors-templates

So for this case you'd need to in an extension or via a custom templates - set the path via Admin->System Settings -> Directories.

Create a file at the following path: custom_templates_folder/CRM/Event/Form/Registration/ThankYou.extra.tpl templates/CRM/Event/Form/Registration/ThankYou.extra.tpl

Then add in the html required. You'll want to wrap everything between {literal}{/literal} tags - i.e.

  <script type="text/javascript">
     Tracking js code here.

This will insert it onto every Event registration page. If you need different codes/tracking for different pages then there is a way to do this by creating a folder with the relevant id -> Form/Registration/2/ThankYou.extra.tpl.

However as you can identify this is not an ideal solution if the person generating and updating codes does not have easy access to upload files to your server.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.