Implementing the Tealium Universal Tag (utag.js) on your website isn't rocket science, but it does require a fair amount of pre-planning and requirements gathering. We have a whole team of implementation specialists dedicated to guiding customers through this initial process. It's a non-trivial amount of work to get a robust implementation deployed to your production site. Which is why it's worth thinking about your long-term strategy for maintaining that implementation.
First, we can all admit that imperfections are bound to arise in your Tealium implementation. As your site goes through weekly or monthly releases, it's inevitable that one of them will interrupt your data layer or tracking. Of course, the flexibility of the iQ Tag Management platform makes it easy to apply one-off fixes. For example, you can use extensions to add missing variables to the data layer, apply fixes to errant values, or set up event tracking -- all feasible tasks within a matter of minutes. But these patches add up over time and will clutter your iQ workspace, making difficult to maintain over the long term. So, you need better strategies to ensure that your implementation remains in tact after each release. So let's talk about unit testing!
Entire software companies exist for this purpose (see ObservePoint). At the same time, adopting a test-driven development (TDD) approach to your Tealium implementation is now easier than ever with the available frameworks such as Mocha and Chai. The following is an example of how you could add a Mocha-based testing suite entirely inside your Tealium iQ workspace.
Then add a Tealium Custom Container tag and paste the contents of each library and the CSS into the tag template between lines 21 and 22 (yes, it's a lot of code, but you won't need to edit this file again):
/* Start Tag Library Code */ // Paste Mocha and Chai code here /* End Tag Library Code */
Next, create a load rule for this tag that triggers the test. In this example, we will use a query string parameter called utest. When utest is set to "mocha" the Mocha/Chai tag loads.
Using the condition on the extension allows you to create separate unit tests for each page type or event that you want to test.
The product page extension tests that the product variables are arrays with a length of 1. It also tests the expected value of the page_type variable.