GA4: gtag customers.gitlab.com
Problems
- Turn off analytics tracking when Global Privacy Control signal is ON for California, Colorado, and Connecticut.
- Enable Google Consent Mode which fill in the data gap for users who opt out of cookie storage for GA4.
Implementations
Gtag Default Script
Place the default gtag
script before the Google Tag Manager and OneTrust scripts across customers.gitlab.com pages. See list of pages below, as not all pages on this subdomain are tracked.
Gtag script logic: By default, deny cookie storage for users from the EU, UK, Peru, etc.; grant cookie storage for all other geolocation. Later on, Google Consent Mode will be enabled on OneTrust, which will dynamically update the values to "denied" or "granted" based on the user's preference.
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('consent', 'default', {
'analytics_storage': 'granted',
'ad_storage': 'granted',
'functionality_storage': 'granted',
'wait_for_update': 500
});
gtag('consent', 'default', {
'analytics_storage': 'denied',
'ad_storage': 'denied',
'functionality_storage': 'denied',
'region': ['AT', 'BE', 'BG', 'HR', 'CY', 'CZ', 'DK', 'EE', 'FI', 'FR', 'DE', 'GR', 'HU', 'IE', 'IT', 'LV', 'LT', 'LU', 'MT', 'NL', 'PL', 'PT', 'RO', 'SK', 'SI', 'ES', 'SE', 'IS', 'LI', 'NO', 'GB', 'PE', 'RU', 'KR', 'CO', 'CA-QC'],
'wait_for_update': 500
});
</script>
OneTrust Geolocation Exposure Script
Expose the country and state IDs from OneTrust by placing the Geolocation Exposure script:
<script>
window.geofeed = function(options) {
// string two digit ISO country code
var country = options.country.toString();
// string two digit state code
var state = options.state.toString();
};
// Call geo-location JSON service
var json = document.createElement('script');
json.setAttribute('src', 'https://geolocation.onetrust.com/cookieconsentpub/v1/geo/location/geofeed');
document.head.appendChild(json);
</script>
Notes:
- The first section is an EXAMPLE of how to store the state ID and country ID in a variable. This part can be removed. We will be using the variables later.
- The second section is the actual script from OneTrust that makes country and state IDs available.
Refer to the Geolocation Exposure script. Push the country and state IDs into the dataLayer event. This can be in the same script as the Gtag script, but it needs to be below it.
<script>
window.dataLayer = window.dataLayer || [];
dataLayer.push({
'event' : 'OneTrustCountryLoad',
'oneTrustCountryId': 'dynamic value of the country id', --e.g. 'US'
'oneTrustStateId': 'dynamic value of the state id' --e.g. 'CA'
</script>
Pages:
- customers.gitlab.com/
- customers.gitlab.com/admins/sign_in
- customers.gitlab.com/buy_pipeline_minutes
- customers.gitlab.com/buy_storage
- customers.gitlab.com/customers
- customers.gitlab.com/customers/confirmation
- customers.gitlab.com/customers/confirmation/new
- customers.gitlab.com/customers/edit
- customers.gitlab.com/customers/password
- customers.gitlab.com/customers/password/edit
- customers.gitlab.com/customers/password/new
- customers.gitlab.com/customers/sign_in
- customers.gitlab.com/customers/sign_up
- customers.gitlab.com/email_confirmations/new
- customers.gitlab.com/invoices
- customers.gitlab.com/payment_methods
- customers.gitlab.com/payment_methods/[payment id]
- customers.gitlab.com/payment_methods/[payment id]/edit
- customers.gitlab.com/payment_methods/new
- customers.gitlab.com/subscriptions
- customers.gitlab.com/subscriptions/[subscription id]
- customers.gitlab.com/subscriptions/[subscription id]/upgrade/new
- customers.gitlab.com/subscriptions/[subscription number]/edit
- customers.gitlab.com/subscriptions/[subscription number]/renew
- customers.gitlab.com/subscriptions/community_program/new
- customers.gitlab.com/subscriptions/new