Tealium
This guide demonstrates how to set up Mixpanel event tracking and identity management with Tealium's IQ Tag Management Platform (opens in a new tab).
Prerequisite: Tag Hooks
Tealium’s iQ Tag Management creates event streams fueled by UDOs (opens in a new tab) (Universal Data Objects).
For web applications, UDOs are just javascript objects with a special shape; they are automatically detected by the Tealium utag SDK (opens in a new tab), and they look like this:
var utag_data = {
"tealium_event": "page_view",
// ^ the key is always 'tealium_event'
// values will depend on your tealium implementation; standards: https://docs.tealium.com/platforms/javascript/track/#tealium_event
//UDOs can contain any number of custom params
"foo: "bar",
"baz": "qux"
}
In order to trigger Mixpanel events based on the values of tealium_event
s, you’ll need to create a variable in Tealium’s data layer for tealium_event
(the key not the value).
This is a very common implementation pattern in Tealium; if you’ve been using tealium for a while, you most likely have already mapped a UDO for tealium_event
... if you haven’t, here are the steps:
find "data layer" in the main menu:
click "add variable":
the type is "UDO Variable"; the source is "tealium_event" ... then click apply:
now save and publish!
you should now see a "tealium_event" variable in your UDOs:
( ^ it should look exactly like this! ^)
we’re now ready to setup mixpanel events with triggers based on the values passed to tealium_event
... these values are usually strings like page_view
, product_view
, search
etc...
Connecting Mixpanel to Tealium
- Find the tags section of iQ Tag Manager:
- Click add tags and find 'mixpanel' using the search
- Click add to bring the Mixpanel tag into your Tealium workspace.
You can now connect your Mixpanel project to Tealium and configure the tag's behavior.
You will need a mixpanel account (opens in a new tab) and a mixpanel project (opens in a new tab) to continue.
In the first section of the tag wizard, enter your mixpanel project token (opens in a new tab) and click Next:
Next, you’ll setup load rules which determine which pages mixpanel will be deployed on.
In order for the mixpanel tag to appear on your pages, you will need to add a condition to your load rules (opens in a new tab) using the wizard. Load rules make it possible to conditionally apply tags in certain cases, based on variables and conditions that Tealium is aware of.
For testing, it’s perfectly fine to say "load on all pages":
Mixpanel should now be deployed on all known Tealium pages of your site. Next, you will set up mappings which fire Mixpanel events based on mappings created in Tealium.
Sending Events
The final section of the tag wizard is where data mappings (opens in a new tab) are configured. Data mappings are essentially a GUI-driven configuration that will compose and deploy javascript snippets on your Tealium-tagged pages (if the load rules are met).
That the goal of this guide is to turn something of this form:
var utag_data = { "tealium_event": "page_view" }
into the equivalent javascript:
mixpanel.track('hello from tealium!')
when a user loads the page.
Here’s how you can setup this mapping:
-
first, we need to use the
tealium_event
UDO variable to tell Tealium to passtealium_event
values to the mixpanel tag: -
click "variables" dropdown and choose "tealium_event"
-
next, in the events menu, we bind the trigger
page_view
(from the UDOtealium_event
) to the mixpanel methodtrack
: -
click 'add’ when it looks like this... and then done
- we should now have this binding:
this will track the UDO page_view
whever it appears on our site.
next, we’ll need to give our event a name in mixpanel...
for this tutorial, we’ll use a custom value (opens in a new tab) ... this is added as another variable in tealium’s data mapper:
- click "variables" drop down and choose use custom value:
- define your "custom value"
- now, in the event parameters menu we need to bind our custom value
hello... from tealium
to theeventName
fortrack
:
- click "add" and "done" when you’ve mapped your custom value to Track : Event Name
our final mapping now looks like this:
if your screen looks similar, you’re ready to save and publish!
we’re almost there! wait a couple moments for tealium to apply the updates to your environment, and then load one of your pages (that has this tag deployed)
if you pop open the developer console in your browser... you can see two requests to mixpanel:
if you’re using a tealium browser extension debugger, (opens in a new tab) or have forced the utag into debug mode by modifying the cookie (opens in a new tab):
document.cookie="utagdb=true";
you can see the tag’s rendering states:
or... you can skip all that debugging noise and just go to mixpanel, and click into the events report (opens in a new tab) to see your new fresh event!
🥳 congrats! you just implemented Tealium → Mixpanel. You will repeat this process for additional events you wish to create.
Adding Event Properties
Because Tealium wraps the Mixpanel JS SDK, Mixpanel's default event properties (opens in a new tab) will be including on every event.
Any "custom" event properties will need to be mapped within Tealium using he following structure: MY UDO ⇒ track.properties.KEY_NAME
where KEY_NAME
is the label you want to use for the property key in mixpanel... the value will be the value of the UDO at runtime:
A single event may have many custom properties mapped; that might look like this:
Adding event properties is as simple as modifying the exsiting mapping to an event, and saving and publishing. Once you trigger your new tage you will the correct UDO value and the label you specified in the mapper show up in mixpanel
note: you can always rename property keys' display labels in lexicon (opens in a new tab)
Cross-device Tracking
important: cross device tracking assumes you know the identity of the current user.. identify()
should only be called on "authenticated" (logged in) pages/actions.
ultimately, we are trying to get Tealium to render this tag:
mixpanel.identify(uniqueUserId)
where uniqueUserId
is a string value that refers to the canonical user id for the current ("logged in") user.
it’s critically important that this value uniquely identifies the end-user, across all devices they may have.
as a side note: some customer are tempted to use an email address as a unique identifier; this is (generally) not a good identifier, especially if users can change their email address... the value you pass to identify
should never change for a single user.
- first, i’ll assume we have a UDO (or other javascript variable) that points to our UUID (unique user identifier)
- next, we have to tell tealium when to use our
identify
tag... this is similar to how we usedpage_view:track
directive to tell tealium to call.track()
on the "tealium event" "page_view" ... you will probably use some other UDO event here (likelog in
orsign in
):
- next, we’ll select our
id_of_user
UDO (or whatever value represents our UUID for the end user) in the dropdown and proceed to SELECT DESTINATION
- finally, we map the
id_of_user
value toevent parameters
for theidentify
event and choose the specific parameterunique ID
... then click ADD
a final implementation of mixpanel within Tealium might look like this:
Was this page useful?