We use GTM for our GA4 config tag and events. However, the CRM site doesn't integrate with GA4. While we have our GTM container installed on it, it hasn't been super reliable to look for the visibility of a thank you message after submitting an important form. The DBA configures the thank you messages and I recently learned that we can include javascript and html in those thank you messages, which would be more reliable.
How would I get a GA4 event to fire when the message is displayed on the page (whether or not the user scrolls to see it))? Do I just embed the gtag('event','eventname'); code in tags within the message ? Does it need any other code to trigger it? Could there be timing issues if the GA4 config tag isn't fired first from the GTM container (it's set to trigger on Initialization)?
I'm not a webdev or programmer, so looking for basic info.
To test it out, I edited a test page on our wordpress site and added:
<script> gtag('event', 'test_inline_ga_event'); </script>
into a random content . But in the console it says "Uncaught ReferenceError: gtag is not defined." Timing issue with the GA4 config tag?
Because I see other GTAG commands (from gtm) firing just fine afterwards. How can I be sure to only fire the command after the GA4 config tag has run?
Thanks! Jannette