After hours of searching and testing, I finally figured out how to add GTM to a Flex event and get it to fire correctly to load the container, fire off page views and a reg conversion event. To save everyone else time, here was my setup:
This one goes in a snippet with the type Initialization:/* initialization snippet */
(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
'
https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
})(window,document,'script','dataLayer','GTM-
YOUR CONTAINER CODE HERE');
/* end initialization snippet */
This one goes in a snippet with the type All website and registration pages:/* pageview snippet */
dataLayer.push({
'event': 'cvent_page_view'
});
/* end pageview snippet */
This one goes in a snippet with the type Registration conversions:/* reg conversion snippet */
dataLayer.push({
'event': 'reg_complete'
});
/* reg conversion snippet */
Here is the
the export of the GTM container that I created to handle pushing the pageviews and registration complete event to GTM. It works for both UA and G4. All you have to do is import and update the IDs with your values (or replace with your settings/config variables). Hopefully no one else will have to spend hours trying to figure this out!
------------------------------
Jennifer Bissex
Maritz
------------------------------
Original Message:
Sent: 02-15-2022 16:35
From: Christy Jenkins
Subject: Google Tag Manager (GTM) installation
Hello! I am trying to assist our marketing team with creation of code snippets for GTM so that we can utilize the snippet within events. With GTM, there are two code snippets needed to be placed -- one in the head, one in the body. I only see an option for one piece of code to be added per code snippet. Can anyone explain how you are setting up these code snippets to work for GTM specifications? I have searched threads but it seems this is not possible as of about a year ago. Any updates? :)
#Flex-Creating/ManagingEvents
------------------------------
Christy Jenkins
Associate Director, IT Program Management � Inform
American Optometric Association
------------------------------