Skip to main content

Data Layer Variables

Variables in Google Tag Manager are named placeholders for values that are populated when code is run on your website or mobile app. For example, the Tag Manager variable named "Page URL" returns the current web page URL. Tag Manager variables are used in both triggers and tags. Create custom user-defined variables in Google Tag Manager to suit specific requirements for WHMCS GTM module.

Google Analytics 4

This documentation will guide you to how to configure the user-defined variables to use with Google Analytics 4 property.

caution

This Data Layer Variables configuration are valid only for Google Analytics v4 (GA4) Properties.

Container Variables

To bind information from WHMCS to the Google Tag Manager through DataLayer, we define a set of variables. To create a new DataLayer 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.

You will need to create the entire set of variables of type Data Layer Variable given in the following table.

Variables for Google Analytics 4

NameData Layer Variable NameDescription
currencycurrencyresponsible to bind the actual currency code of shopping cart.
EcommerceItemsecommerce.itemsCollection of products/services from the order.
languagelanguagecurrent WHMCS user language (ex.: english).
localelocalecountry locale code based on the session language (Ex.: en_GB).
loggedinloggedinboolean value that identify if user is logged in, true when logged in and false when not.
templatetemplatethe template name used on user session (ex.: six).
transactionAffiliationecommerce.affiliationFilled when an order has an affiliation or referral (WHMCS affiliation ID).
transactionCouponecommerce.couponthe coupon code used in a order.
transactionIdecommerce.transaction_idthe unique transaction ID of every order placed, refers to the WHMCS Order ID.
transactionTaxecommerce.taxused to bind the tax value on orders.
transactionValueecommerce.valueused to bind the monetary transaction value on orders.
userTypeuserTypeused to identify the user type: visitor when user is not identified and client when logged in.
valuevalueused to measure events value.
info

From v4.1.3 the variable userID was removed due to conflict with GA property with same name.

Google Analytics 3

This documentation will guide you to how to configure the user-defined variables to use with Google Analytics 3 property.

Container Variables

caution

This Data Layer Variables configuration are valid only for Google Analytics v3 Properties.

To bind information from WHMCS to data layer we will use personalized GTM data layer variables. To create a new data layer variable go to Variables and click on the New button.

Click on the dialog box to choose a variable type and search for Data Layer Variable type.

You will need to create the entire set of variables of type Data Layer Variable given in the following table.

Variables for Google Analytics 3

All variables listed below is of the type Data Layer Variable.

NameData Layer Variable NameDescription
currencyCodeecommerce.currencyCoderesponsible to bind the actual currency code of shopping cart.
eventCategoryeventCategoryused to categorized WHMCS events.
eventLabeleventLabelused to labeled WHMCS events.
eventTypeeventTypeused to track WHMCS events type
eventValueeventValueused to mensure WHMCS events value and purchase value conversion.
languagelanguagecurrent WHMCS user language. Ex.: english.
loggedinloggedinboolean value that identify if user is logged in, true when logged in and false when not.
localelocalecountry locale code based on the session language. Ex.: en_GB.
pageTitlepageTitletitle tag value.
purchaseIdecommerce.purchase.actionField.idWHMCS order ID for purchase and conversion tracking.
templatetemplatethe template name used on user session. Ex.: six.
userIDuserIDif the visitor is logged in, this variable will be filled with the WHMCS client ID.
userTypeuserTypeused to identify the user type: visitor when user is not identified and client when logged in.
valuevalueused in order value with tracking conversion.

WHMCS variables example