Google Tag Managerby mokusiga on 05/26/2013
Questions and Answers to the “Google Tag Manager – Mokusiga” plugin I’ve created for WordPress
- In your template’s header file, place something like <?php do_action(‘gtm_hook’); ?> to where you want the GTM code to load.
- In the settings, select ‘custom’ and fill in ‘gtm_hook’ (without quotes).
- Save the settings.
- The GTM code should now appear where is defined.
What is my Container ID?
This is the ID used to identify your Google Tag Manager container. Assuming that you’ve already created a container within Google Tag Manager, you can find this by logging in to www.google.com/tagmanager and selecting the container. And then in the left hand menu, select
Users & Settings\Settings. You will see a textfield like below. The GTM-XXXX value is your container ID.
- Option ‘footer’: select ‘footer’ and the Google Tag Manager code will appear in the footer. This is the default for this plugin because most wordpress plugins support the wp_footer() hook.
- Option ‘custom’: select this option if you want to place the Google Tag Manager code elsewhere. You would need to add the hook manually to your theme. See how to add the script to after the <body> tag
What is the dataLayer name?
The datalayer variable is used to pass key/value variables into Google Tag Manager. The plugin allows you to change the datalayer name if it conflicts with your existing scripts. The default is ‘dataLayer’ and for more information, see renaming data layer.
How do I use the dataLayer?
Please see Using a Data Layer .
What is my dataLayer variable for logged in users?
Check this to enable a data layer variable to indicate if the current user is logged in or not. Using this, you can add custom variables (Google Analytics) or custom dimensions (Universal Analytics) to the tracking code.
The key of this variable is
'isLoggedIn' and the value would either be