This section enables you to integrate Google Tag manager with Beehive. To activate the integration, start by clicking the Activate button.
Note that if you have already integrated Google Analytics with your Google Tag Manager account, you do not need to connect Analytics to Beehive; the Tag Manager container you connect will handle that for you.
If you have not connected Analytics to Tag Manager yet and wish to do so, below are Google’s guides to help you get that done.
For older Universal Analytics accounts, see: Deploy Universal Analytics with Tag Manager
For newer Google Analytics 4 accounts, see: Google Analytics 4 tags
10.4.1 Account (Tag Manager)
Add your Google Tag Manager container ID (GTM ID) in the field provided and click Save Changes. If you’re not sure where to find your GTM ID, see this Google help doc.
PRO TIP
If you are testing things on a staging site, you can create and use different Container IDs for your live and staging sites so your live GTM data doesn’t get “polluted” with staging data.
10.4.2 Settings (Tag Manager)
In the Settings section are several built-in variables that you can enable, and you can define your own custom ones as well if needed.
You can use the data in your Google Tag Manager account as you see fit. If you need help with that, see this Google doc: https://support.google.com/tagmanager/answer/6164391
Default
Under the Default tab, you’ll find a number of post-related variables are built-in. Enable the ones you need by clicking the toggle on the left.
Visitors
Under the Visitors tab, you’ll find several variables related to the current visitor’s status. Enable the ones you need by clicking the toggle on the left.
Integrations
Under the Integrations tab, you’ll find variables related to currently supported plugins or services. At this time, WPMU DEV’s Forminator and Hustle plugins are supported. Note that if any plugin is not active, their options will appear greyed out here.
When any of the integration options are enabled for Forminator, and a form/poll/quiz is submitted successfully, Beehive will send a Data Layer event with form/quiz/poll data to GTM. The event names are:
- beehive.forminatorFormSubmit (for Form)
- beehive.forminatorPollSubmit (for Poll)
- beehive.forminatorQuizSubmit (for Quiz)
When integration is enabled for Hustle Leads, and an optin module is successfully submitted, Beehive will send a Data Layer event with module data to GTM. The event name is:
- beehive.hustleModuleSubmit (for all modules)
Excluding Forminator Field Data
If you need to exclude certain Forminator field data from the DataLayer sent to your Google Tag Manager, you can use the beehive_gtm_forminator_excluded_fields filter in your active theme’s functions.php file or a mu-plugin.
For example, you could anonymize the data sent to GTM by excluding the Name & Email fields from all forms using the code below. Add any additional field names on new lines as in this example. Note however that it is not possible to specify a form ID, so the specified field data from all forms would be excluded.
add_filter( ‘beehive_gtm_forminator_excluded_fields’, function ( $fields, $type, $network ) { | |
$fields[] = ‘name-1’; | |
$fields[] = ’email-1′; | |
return $fields; | |
}, 10, 3 ); |
This filter can also be used to exclude field data from quizzes or polls. Just remember to specify the field names for these uses as well, not the IDs. For example, the answer field name from a poll could look like answers[question-3410-549], and from a quiz, it could look like 931.
There is unfortunately no equivalent filter for Hustle optin forms. This may be included in a future update however.
Custom
Under the Custom tab, you can define your own custom variables if needed. To add a variable, click the Add Variable button, then enter the Name and Value, and click Save Changes.
Verifying data sent to GTM
You can see exactly which data is being sent to your connected GTM account by toggling on the Preview feature in your GTM workspace to open the TagAssistant. Then visit any page on your site and check the output under the Data Layer tab on the TagAssistant screen.
If you have enabled integration options with Forminator, submit a Forminator form/quiz/poll from your site, and you’ll see data similar to the below example, where you can also see all the form field variables along with the defaults and any custom ones you may have added.
If you have enabled the integration with Hustle, an optin module submitted from your site would send data similar to the below example, along with the default and custom variables as well.