Container Variables
Understanding Container Variables
In Google Tag Manager, variables serve as placeholders for values that are filled in when code executes on your website or mobile app. For instance, the "Page URL" variable in Tag Manager provides the current web page URL. These variables are essential components used in triggers and tags.
This guide provides comprehensive instructions for creating User-Defined Variables in Google Tag Manager to link information from WHMCS to your container via Data Layer. These user-defined variables will be populated with data from WHMCS and can be readily utilized in triggers and tags throughout your setup.
In Container Tags section we will provide an essential yet comprehensive set of tags that will use these variables. But you are free to use them in any other tag that your marketing strategy requires.
How to Create Variables
To create a new Data Layer variable in your container for using with GA4 property go to Variables -> New
.
Click on the dialog box Variable Configuration
to open the choice options and on the right panel select the variable type Data Layer Variable
.
All variables needed for the module Google Tag Manager for WHMCS are split in sections to better understanding. Below is a list of the variables that you need to create in your Google Tag Manager container.
If you are upgrading from version 4.1 or older, some variables are deprecated and will not be available on Data Layer in future updates. These variables will be indicated on they description. We recommend you to migrate to the new equivalent variables as soon as possible.
Google Tag & Measurement ID Variables
To simplify the configuration and minimize tag duplication, you can create a variable to store the Google Tag ID and Measurement ID. This variable will be used in all tags that require these IDs.
Google Tag ID
- name: Google Tag ID
- Variable Type: Constant
- Value: YOUR-GOOGLE-TAG
Google Measurement ID
- name: Google Measurement ID
- Variable Type: Constant
- Value: YOUR-GOOGLE-MEASUREMENT
WHMCS Variables
Below is a list of the variables that you be used to identify some information about your WHMCS that will be available to use in any triggers and tags.
Name | Data Layer Variable Name | Description |
---|---|---|
WHMCS - Currency | currency | responsible to bind the actual WHMCS selected currency code of shopping cart. (deprecated) |
WHMCS - Currency | whmcsData.currency | responsible to bind the actual WHMCS selected currency code of shopping cart. (added in v4.2) |
WHMCS - Language | language | current WHMCS user language (ex.: wn). (deprecated) |
WHMCS - Language | whmcsData.language | Current selected WHMCS language on user session (ex.: en). |
WHMCS - Locale | locale | country locale code based on the session language. (deprecated) |
WHMCS - Locale | whmcsData.locale | country locale code based on the session language. |
WHMCS - Template | template | the template name used on user session (ex.: six). (deprecated) |
WHMCS - Template | whmcsData.template | the template name used on user session (ex.: six). |
WHMCS - Order Form | whmcsData.order_form | the order form name used on user session (ex.: standard_cart). |
User Variables
User variables are used to identify the user type and some information about the user that will be available to use in any triggers and tags.
The table below shows the user variables that you need to create in your Google Tag Manager container.
Name | Data Layer Variable Name | Description |
---|---|---|
UserType | userType | used to identify the user type: visitor when user is not identified and client when logged in. (deprecated) |
User Data - Type | userData.user_type | used to identify the user type: visitor when user is not identified and client when logged in. |
User Data - Loggedin | loggedin | boolean value that identify if user is logged in, true when logged in and false when not. (deprecated) |
User Data - Logged In | userData.logged_in | boolean value that identify if user is logged in, true when logged in and false when not. |
User Data - Language | userData.language | Current language code used on user session . |
User Data - UUID | userData.user_uuid | WHMCS Client UUID. |
User Data - Currency | userData.currency | User currency code. |
To enable User-ID collection in Google Analytics 4 please refer to the User-ID collection documentation.
Customer Variables
Customer variables are used to identify the customer type and some information about the customer that will be available to use in any triggers and tags.
The table below shows the customer variables that you need to create in your Google Tag Manager container.
Name | Data Layer Variable Name | Description |
---|---|---|
Customer Data - UUID | customerData.customer_uuid | WHMCS Client UUID. |
Customer Data - Status | customerData.customer_status | WHMCS Client Status (Active/Inactive). |
Customer Data - Email | customerData.email | WHMCS Client Email. |
Customer Data - Email (hash) | customerData.email_hash | SHA256 WHMCS Client Email hash. |
Customer Data - First Name | customerData.first_name | WHMCS Client First Name. |
Customer Data - First Name (hash) | customerData.first_name_hash | SHA256 WHMCS Client First Name hash. |
Customer Data - Last Name | customerData.last_name | WHMCS Client Last Name. |
Customer Data - Last Name (hash) | customerData.last_name_hash | SHA256 WHMCS Client Last Name hash. |
Customer Data - Phone | customerData.phone | WHMCS Client Phone. |
Customer Data - Phone (hash) | customerData.phone_hash | SHA256 WHMCS Client Phone hash. |
Customer Data - Company | customerData.company_name | WHMCS Client Company. |
Customer Data - Street | customerData.address.street | WHMCS Client Street. |
Customer Data - City | customerData.address.city | WHMCS Client City. |
Customer Data - Region | customerData.address.region | WHMCS Client Region/State. |
Customer Data - Country | customerData.address.country | WHMCS Client Country. |
Customer Data - PostalCode | customerData.address.postal_code | WHMCS Client Postal Code. |
To see how to use customer data to enhance your Google Ads campaigns, please refer to the Google Ads documentation.
Ecommerce Variables
Ecommerce variables are used to identify the ecommerce type and some information about the ecommerce that will be available to use in any triggers and tags.
The table below shows the ecommerce variables that you need to create in your Google Tag Manager container.
Name | Data Layer Variable Name | Description |
---|---|---|
Ecommerce Data | ecommerce | Collection of ecommerce data. |
Ecommerce Data - Items | ecommerce.items | Collection of products/services. |
Ecommerce Data - Value | ecommerce.value | Monetary transaction value. |
Ecommerce Data - Tax | ecommerce.tax | Tax value on orders. |
Ecommerce Data - Affiliation | ecommerce.affiliation | Affiliation or referral. |
Ecommerce Data - Coupon | ecommerce.coupon | Coupon code used in a order. |
Ecommerce Data - Transaction ID | ecommerce.transaction_id | WHMCS Order ID. |
You can create additional variables as your request to store specific information about your products and services. For example, you can create a variable to store the product category or the product PID that is available inside the Ecommerce Data - Itens.
Event Settings Variable
Google Tag: Event Settings variable is a reusable variable that contains settings for Google tags and GA4 Event tags. For WHMCS, this variable is used to store some user data that are available across multiple events.
To creat e a new Google Tag Event Settings variable go to Variables -> New
.
Click on the dialog box Variable Configuration
to open the choice options and on the right panel select the variable type Google Tag: Event Settings
. Under the Google Analytics User Properties tab, add the follow properties:
Property Name | Value |
---|---|
language | {{User - Language}} |
logged_in | {{User - Logged In}} |
user_type | {{User - Type}} |
template | {{WHMCS - Template}} |
For more information about Google Tag Event Settings please visit Google official documentation https://support.google.com/tagmanager/answer/13438771?hl=en
User-Provided Variable
User-Provided Data is a variable that stores the user data that is provided by the Data Layer on your WHMCS. Having this variable is required when you enable Enhanced Conversions for Web feature.
To create a new User-Provided Data variable go to Variables -> New
, click on the dialog box Variable Configuration
to open the choice options and on the right panel select the variable type User-Provided Data.
On Type option, select Manual Configuration, under each field select the respective variables from the Customer Data group.
Field Name | Value |
---|---|
{{Customer Data - Email (hash)}} | |
Phone | {{Customer Data - Phone (hash)}} |
Under Name and Address tab, set the respective variables from the Customer Data group.
Field Name | Value |
---|---|
First Name | {{Customer Data - First Name (hash)}} |
Last Name | {{Customer Data - Last Name (hash)}} |
Street | {{Customer Data - Street}} |
City | {{Customer Data - City}} |
Region | {{Customer Data - Region}} |
Country | {{Customer Data - Country}} |
Postal Code | {{Customer Data - PostalCode}} |
Google Services expect PIIs to be hashed before sending them to Google. The module will provide on Data Layer hashed and non-hashed values, ensure that you are using the correct one.
To know more about User-Provided Data, visit About enhanced conversions and Set up enhanced conversions for web using Google Tag Manager documentations.
User-ID Attribution Variable
User-ID Attribution is a variable that stores the user ID that is provided by the Data Layer on your WHMCS. Having this variable will allow you to record the defined User-ID Attribution.
- Name:
User-ID Attribution
- Variable Type:
Data Layer Variable
- Data Layer Variable Name:
user_id
To learn more about User-ID attribution visit Measure activity across platforms with User-ID documentation.