customTask Guide by Simo Ahava
The customTask API is a feature of the Universal Analytics library (used by Google Tag Manager’s tags, too). It lets you get and set values from and to the (Measurement Protocol) hit as it’s being generated. This is really useful for a couple of reasons, which I’ve covered in the previous articles, but I’ll go over them briefly in the beginning of this guide, too.
Suffice to say that especially for Google Tag Manager, customTask adds a lot of value. With GTM, it’s always been quite difficult to access the hit-building process when using tag templates. Luckily, customTask offers a solution to this problem, and at least for this particular developer it’s opened a whole new world of Google Analytics customization.
Things you can do with customTask
1. Set Client ID as a Custom Dimension
2. Duplicate Google Analytics tags to more than one property
3. Track offline users in Google Analytics
4. Remove PII from GA payloads
5. Fix site speed sampling messing with your Custom Metrics
6. Respect opt-out
7. Send details about Optimize experiments to Google Analytics
8. Auto-link domains with regular expressions
9. Send Google Analytics payloads to Snowplow
10. Send Google Analytics payload length as a Custom Dimension
11. Send Hit Type as a Custom Dimension
12. Automatically reduce payload length
13. Create and update a session cookie
14. Tracking cross-domain iframes
15. Prevent duplicate transactions from being sent
16. Obfuscate and duplicate Google Analytics data
However, in spite of writing all those articles on customTask, I recently realized that I never actually took the time to explain more thoroughly how it works. Also, I haven’t yet shared solutions for combining multiple customTask tricks in a single tag. This guide seeks to address these points…
Read more here: customTask – The Guide | Simo Ahava’s blog.