Most Advanced GTM Deployment. Ever!

Preview:

Citation preview

#emetrics @PHILPEARCE

New York 26th Oct 2016

Learnings from the most Advanced GTM Deployment I have ever done!

(On a site with 1 billion hits a month) By Phil Pearce

I`m an Analytics Adventurer & Explorer!

I recently did 8 countries in 12 weeks = 4.6 days per country

Agenda 1. Set the scene

– Size – Complexity – Timelines

2. How we got there – Tools – Strategy

3. Conclusion & take always – Checklist / Solution Library

4. Questions

Last week I did a twitter survey….

“How many Google Tag Manager installations have YOU done?”

1. Newbie: 1-3 installation 2. Experienced: 4-10

installation 3. Advanced: 10+ installation

Survey results https://plus.google.com/117298997433687198127/posts/dW5TjdS7XEV https://twitter.com/philpearce/status/779678727861104640

Super Experienced people

AdWords …I have done alot more than 10 GTM & GA Implementations

This is the story of

one such implementation…

So, a beautiful but HUGE new client just signed!

• 400 man-hours GTM project • 600 GA classic events • GA classic to Universal pageview migration • Inhouse TMS.js migration to GTM • 6 CMS platforms • Only 3 months to complete! • Fine per task, if not completed within the timeline!

Project Complexity

Source: builtwith.com/detailed/behemothclient.com

Over 6+ CMS platforms & multiple analytics solutions!

Project Size

Huge site!

Number of pages indexed on Google

2,680,000 results

350,000 results

Switch from GA classic to GA universal

Migrate existing 200 GA events in GTM

Add 400 GA events (auto-events)

Move pageview from TMS.js (inhouse TMS) into GTM

Preliminary GTM account audit

Behemoth

Project Timeline to climb the mountain

3 month Deadline…

If missed = financial penalties per task!

In Reality…

Inhouse IT dept slow to respond, thus impossible to enforce the task based fines.

How did we get to the Summit?

And more importantly...

• What went right?

• What went wrong?

The Win was deliver by Technical & Tactical working together!

Business Technical

Plus lots of Tools & Techniques!

Technical (Phil) • Testing Tools • Strawman Test environment • Separate DEV & LIVE environments • Auto-QA • Failsafe deadman switch • Security • Governance of Logins & access levels • Controlling Risk factors

Tactical (Agency) • Task prioritisation

• Split based on “required client dependencies”

• Sorted based on cost vs benefit • Weighted based on strategically

important items

Wins Mistakes Wins Mistakes

Tools

Technical

GA classic >> GA universal

migration comparison +/-2%

Pass

+2%

Fail -10% Compare on: 1. Pageview Then… 2. Sessions Then.. 3. Users

Start with • Hostname

GA classic pageTracker

GA universal secondTracker

GA classic >> GA universal

migration comparison +/-2%

Pass

+2%

Fail -10% Compare on: 1. Pageview Then… 2. Sessions Then.. 3. Users

GA classic pageTracker

GA universal secondTracker

Check in this order: 1. Hostname 2. Referral domains 3. ContentGroups 4. Folders 5. URLs

GoogleSheet highlighted exclude referrals & missing domains

e.g. paypal.com exclude referral was missing!

PII safeguards

…to prevent GA account deletion!

PII prevention filters PP01a: TidyURL - Replace email with EMAIL-OBFUSCATED-BY-FILTER@gmail.com (start of string) URL (.*?)(=|%3D)([a-zA-Z0-9_.+\-]+(@|%40)[a-zA-Z0-9\-]+\.[a-zA-Z0-9\-.]+)($|&.+)

Output URL $A1=EMAIL-OBFUSCATED-BY-FILTER@gmail.com$A5

PP01b: TidyURL - Replace email with EMAIL-OBFUSCATED-BY-FILTER@gmail.com (end of string) URL (.*)(=|%3D)([a-zA-Z0-9_.+-]+(@|%40)[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)($|&.+)

Output URL $A1=EMAIL-OBFUSCATED-BY-FILTER@gmail.com$A5

PP02a: Tidy EventLabel - Replace email with EMAIL-OBFUSCATED-BY-FILTER@gmail.com (start of string) EventLabel (.*?)(=|%3D)([a-zA-Z0-9_.+-]+(@|%40)[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)($|&.+)

Output EventLabel $A1=EMAIL-OBFUSCATED-BY-FILTER@gmail.com$A5

PP02b: Tidy EventLabel - Replace email with EMAIL-OBFUSCATED-BY-FILTER@gmail.com (end of string) EventLabel (.*)(=|%3D)([a-zA-Z0-9_.+-]+(@|%40)[a-zA-Z0-9-]+\.[a-zA-Z0-9-.]+)($|&.+)

Output EventLabel $A1=EMAIL-OBFUSCATED-BY-FILTER@gmail.com$A5

Generic PII exclude params

PP_list_lastchecked_2016_10_30, password, password_confirmation, regCode, username, username_confirm, signin[username], signin[runas], signin, sign_in, conf, gpid, obem, inf_contact_key, user_id, userId, username1, frmUsername, nickName, qz_user_name, url_mac, Email, email, mail, MAIL, feedback_email, newEmailAddress, newemailaddress, emailAddress, emailaddress, recipientName, recipientEmail, MMDB_ID, mmdb_id, EMAIL_ID, email_id, email[body], email[subject], interaction[email], interaction[name], CVC_M1RSUBNM, CVC_M1RADDR1, CVC_M1RADDR2, CVC_M1RCITY, CVC_M1RSTATE, CVC_M1RCTRYC, CVC_M1RZIP, CVC_M1REMAIL, CVC_M1RTACCT, MSRSUBNM, MSRADDR1, MSRADDR2, WESCITY, WESSTATE, WESZIP, MSREMAIL, Name, selectedAddress, selectedAddres_0, selectedAddres_1, selectedAddres_2, selectedAddres_3, selectedAddres_4, selectedAddresSize, Address1, Address2, City, State, Zip, zipcode, qz_user_country, state, oauth_token, oauth_verifier, rptregcta, rptregcampaign, nickName, selectedAddress, username1, frmUsername, mac_address

Auto-QA

Auto-QA feedback loop… bit.ly/qatemplate

EventID

(GoogleSheet)

Added to each

GTM tag

GA api

(Googlesheet)

vLookup

(GoogleSheet)

Note: Ensure CustomDimension[20] enabled in GA settings

Auto-QA feedback loop… bit.ly/qatemplate

EventID

(GoogleSheet)

Added to each

GTM tag

GA api

(Googlesheet)

vLookup

(GoogleSheet)

Auto-QA feedback loop… bit.ly/qatemplate

GTM auto-event config file bit.ly/gtmconfig (For any CMS)

Reminder: open the import files in notepad, then find & replace “yourdomain” and “yourdomain\\.com” with YOURDOMAIN before import.

Separate GTM-live & GTM-Dev

1. Server-side switch example

2. Client-side switch example <!– Client Side Switch: Google Tag Manager: Output myGTMID -->

<script>

var myHostname = window.location.hostname;

var myGTMID = 'GTM-xxx1'; // LIVE

if(myHostname === 'staging.behemothclient.com' || myHostname === 'localhost'){

myGTMID = 'GTM-xxx2'; // DEV

}

</script>

<!-- Google Tag Manager --> <noscript><iframe src="//www.googletagmanager.com/ns.html?id=GTM-xxx1"

height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>

<script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':

new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],

j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=

'//www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);

})(window,document,'script','dataLayer', myGTMID);</script>

<!-- End Google Tag Manager -->

Note: This method can not be used on JSvariables only Custom HTML tags.

3. Tag annotation & Failsafe block

Disable CustomHTML, but allow JS variables. <script>

/* Working example: bit.ly/deadman-switch */

window.dataLayer = window.dataLayer || [];

dataLayer.push({"gtm.whitelist":

["google", "customPixels", "nonGooglePixels", "nonGoogleScripts", "jsm", "flc", "fls", "k"]

});

</script>

Disable CustomHTML and JS variables (breaks any JS lookup table wildcards) <script>

window.dataLayer = window.dataLayer || [];

dataLayer.push({"gtm.blacklist":

["customScripts"]

});

</script>

4. The Deadman switch example

Thankfully this was never used! Note: alternative method for inline method to disable specific script was considered: <script>

window.dataLayer = window.dataLayer || [];

dataLayer.push({"hasPreventGTMscrollTrackingBeenSet": true});

var hasPreventGTMscrollTrackingBeenSet = true;

</script>

Local Test Environment "Strawman unit tests"

Local Test Environment

Working Example here: bit.ly/strawman-test2

Click to switch versions

JS error benchmarking period before Custom HTML changes deployed. Note: 10% client-side sampling used on errorTracker

JS error tracking

Tactical (Business)

Business

Project Scope/Tasks

Original scope… TMS.js migration UA pageview migrations 400 gtm event migrations 200 inline event migrations - 20 second heartbeat - Scroll tracking - Link Listeners (Outclick, PDF, social) - Videos (2 video players) - Donation ecommerce transactions

Added to scope… GTM account clean-up (inc Naming conventions) DEV vs LIVE environments HTML Sandboxes UniversalSecondTracker GA testing profiles SSL tag issues CustomVariables >> CustomDimenssions Subscription Ecommerce tracking Cross-domain tracking

No client involvement: GA Settings:

1. Copy the 5 Goals from the TEST profile view to LIVE profile view

2. Create profile view for CART converted and CART non-converted

3. Create profile view for backend rolledup for Apps and Apps for userID

4. Improving organic by 1.5% by updating channel groupibehemoth

No client involvement: GTM config

1. Subscription e-commerce tracking via DOM scrapping

2. Enable Donate ecommerce revenue tracking

3. Consolidating 27 remarkting tags into 4 tags.

4. Reviewing & fix the remaining 178 triggers for errors.

5. Enable Adwords Dynamic remarking using lookup tables

6. Reducing self referrals from 1% to 0% by enabling legacyHistoryImport.

7. Adding FB and Twitter widget tracking

8. Adding App download & Tap to Call auto-event tracking

Split Client dependencies part1

Task list (The "What")

Milestones & Deadline planning (The "When")

bit.ly/ga-timeline2

262 Tags, 255 rules and 107 macros!

Standardise the naming convention for Tags, Triggers, Variables

GA pageview trigger example

Consolidated!

GTM Before vs After

• After (3 months later)

• Before (before work started)

-33% Reduction in Tags

-39% Reduction in Triggers

Problem: Lots of configuration mistakes by client Solution: Manual clean-up by senior analyst

Solution: Utilise newer feature such as auto-events, lookup tables & tag templates

One BIG pile of spaghetti! Inhouse GTM config built-up

over a 3 year period with 3+ users

Governance: Controlling multiple-user changes...

...whilst plane is in mid-flight!

Risk of accidentally publishing other users changes!

Multiple users: Check-in/Check-out

Solution1: Check-in/Check-out processes and enforce View | Edit access.

Email Role Account Permissions

01. LIVE

02 DEV

phil@agency.com Administrator manage users edit publish

dave@agency.com Tester view

brian@client.com Administrator manage users view view

mary@client.com Administrator manage users view view

mathew@client.com Tester view view

devtools@client.com Tester view

When Check-out set to read-only

Solution2: Create User sandboxes User1 | User2 >> DEV >> LIVE

Multiple users: sandboxes

Email Role Job title Account Permissions

01. LIVE

02 DEV

Marys Sandbox

Mathews Sandbox

phil@agency.com Administrator Implementation Specialist manage users edit publish view view

dave@agency.com Tester Project Manager view

brian@client.com Administrator Systems Admin manage users view view view view

mary@client.com Administrator Analyst manage users view view publish view

mathew@client.com Publisher Marketing Manager view view publish

devtools@client.com Tester Robot Unit Tester view

GTM-xxx1 GTM-xxx2 GTM-zzzz GTM-xxxx

GTM user access audit bit.ly/gtm-access-audit2

Also see David Vallejo`s free API based user-access tool here: www.thyngster.com/gaupet-release-google-analytics-user-permissions-exploring-tool

Summary of safety features

1. 2 stage authentication

2. PII protection - via GA filter on URI & eventLabel

3. JS error tracking profile

4. Inline switch for GTM-DEV / GTM-LIVE (can be client-side or serverside method)

5. Failsafe/deadman`s switch (dataLayer whitelist)

Unexpected avalanches...

Exceeded monthly hit limit!

Note: Hit Tiers above has changed after this project was completed, so there`s now more granular tiers.

$$$

Solution: renaming universal object “ga” to “ga2”

A/B testing tool was sending GA event hits to all trackers on every page = 3x hits

Moving TMS.js pageview into GTM was delayed due to clients fragmented codebase

WPF 1st pageview script

images.behemothclient.com/wpf/CACHE/js/6f599508e0a4-cb1424263825.js

images.behemothclient.com/wpf/sites/common/j/analytics.js

www-s.behemothclient.com/wpf/sites/common/j/analytics.js

WPF 2nd pageview script on Members section

media-mmdb.behemothclient.com/static-media/js/analytics.js

WPF 3rd pageview script on Gallery buttons

images.behemothclient.com/wpf/sites/common/j/jquery.address-1.3.1-grant.min-cb1299116789.js

WPF 4th event script on Members section

assets.behemothclient.com/behemoth-header/build/lib/analytics.js

Deployed via GTM flag... First method not effective as not a common field :( _gaq.push(['_setCustomVar', 5, 'flag', '_gtmDeployed', 3]);

ga('secondaryTracker.set', 'dimension20', '_gtmDeployed');

Second method worked a charm! var flag = document.title + '_gtmDeployed';

_gaq.push(['_title', flag ]);

ga("secondaryTracker.set", {title: flag});

Note: filter to clean-up the page title was required...

PP01a. EXCLUDE hits not deployed via GTM Exclude filter for PageTitle (.*)_gtmDeployed$

PP01b. CLEAN PageTitle PageTitle (.*)_gtmDeployed$

Output PageTitle $A1

PP02. INCLUDE pageview hits only Include hitType=^pageview$

Set utmz cookie - so that inline gaq.push events still work, but don’t effect hitlimit

Solution: _initData var _gaq = _gaq || []; _gaq.push( ['_setAccount', 'UA-1-1'], ['_addIgnoredRef', {{Page Hostname}} ],

['_addIgnoredRef', {{Page Hostname - www removed}} ], ['_setDomainName', {{jsm_setTopLevelDomain}} ], ['_setAllowLinker', true], ['_initData'] );

plus.google.com/117298997433687198127/posts/McER3buexek

https://plus.google.com/117298997433687198127/posts/R5r3Bp88ir7

Creative solution: Enable cross-domain tracking in the Cart funnel without IT dept involvement

Automatic Process Summary (Dec 23rd, 2015)

Project Successes: Phase(s)

Efficiency improvements

• Less time used on client meetings.

• More focused on completing tasks.

However… client slow to action tasks

7 day wait

"Awaiting Agency" tasks very low :)

Training

Human Error on import & publish which caused untested & broken version to be accidentally deployed to LIVE!

Solution: User training & 2 people used to verify go-live changes.

Wrong version accidentally deployed

Need to prevent this happening again...

Client Training • analyticsacademy.withgoogle.com/course/5 • cardinalpath.com/training/google-analytics/analytics-301/ • lynda.com/Google-Tag-Manager-training-tutorials/ • measureschool.com/products/

bit.ly/gtmplaylist

Project Learnings/Improvements

1. Remove "human factor" (e.g. manual export from DEV to LIV)

2. Auto-QA change to use TagID and auto-detect if new GA event added in GTM.

3. Enforce GTM audit at the beginning (not optional task) 4. Enforce a Project summary and feedback session at the end of every

phase (not optional task) 5. Move onto insight, dashboards, A/B testing or BigQuery sooner.

Unexpected wins

1. 1000 tags consolidate to 500 tags reduce gtm.js download size.

2. Reduction in JS errors after TMS.js change to GTM auto-events

3. Much easier to maintain pageview triggers.

4. SSL tag issues fixed

5. Cross-domain tracking was done without IT involvement using JS variable script.

6. VideoProvider tracking was done without IT involvement using DOM scrapping.

7. Ecommerce revenue enabled via DOM scraping.

8. Taxonomy data sent to enhanced ecommerce was very useful for content analysis.

Checklist of Tools…

Life saving tools bit.ly/gtm-checklist

Technical (Phil) 1. +/-2% migration comparison sheet:

bit.ly/ga-api-example 2. Auto-QA sheet:

bit.ly/qatemplate 3. GTM auto-config file: bit.ly/gtmconfig 4. DEV strawman examples: bit.ly/strawman-test2 5. GTM developer guide: bit.ly/gtmdevguide2

• Script for "Deployed via GTM flag" to find inline GA scripts (without using a crawler)

• Script for _initData to sustain gap.push events

Tactical (Agency) 1. Resource planning Gantt sheet:

bit.ly/ga-planning-chart2 2. Deadline planning sheet:

bit.ly/ga-timeline2 3. GTM user access audit:

bit.ly/gtm-access-audit2 4. GTM audit template:

bit.ly/gtm-audit-template 5. Free GTM Training videos:

bit.ly/gtmplaylist

Thankyou & Questions Phil Pearce Senior Web Analyst and GTM specialist

phildpearce@gmail.com

linkedin.com/in/philpearce

Web

Analytics

Exchange

mentor

750 GA

questions answered Tracking

protection

group

Free Prize for the best question(s).

bit.ly/gtmdevguide2 (free) Prize: GTM developer guide

free!! bit.ly/gtmdevguide2