1

I am using MixPanel with a Laravel implementation. I have set up logic to set the 'UTM Source' based on our business requirements. This includes; $referrer, $social, $email, $organic, $network and $facebook_ad. These are working well and as expected to track our needs.

The default value for 'UTM Source' is set to '$direct'. So if none of the other conditions is set above it will always be set to '$direct'

This code is run on every page load of the website, including internal navigation. So if a user does the following:

/page-a then navigates internally to /page-b, both of these will be attributed as '$direct'.

My question is should the default be blank and then only set $direct under certain conditions?

I say the answer is either no, or $direct only needs to be set on the first arrival to the website. If it's the latter, how would this be accomplished in Laravel? i.e. set this only if the user returns to the site after x hours?

How would the MixPanel JS implementation handle this use case?


Update, with help from @BNazaruk. We have found the following information from MixPanel's website:

https://docs.mixpanel.com/docs/tracking/how-tos/tracking-utm-tags

"An initial referrer is equal to $direct when a user first lands on a site without being referred by another website."

So my updated question is how long should we wait to set direct again after the user has first landed on the website? 1-hour / 1-day / 1-week / indefinitely?

I'd guess in Laravel we'd need to set a cookie to track this time. When the cookie expires, we set $direct again.

1 Answer 1

-1

Short answer: in 99% of cases, backend (Laravel in this case) should know nothing about UTM params and should not ever touch them. Read or write.

An analytics system has a series of methods by which it determines what channel to assign to every hit, essentially. It mostly uses referrers and query params and then assigns the channel it concluded from the first hit to all the hits in a session. This channel propagation normally happens on the mixpanel's backend. An analytics system typically assigns Direct when it doesn't have a referrer or query param to rely upon.

UTM parameters are meant as a simple non-technical override for the default behavior when a non-technical person (like a marketeer) wants to publish an ad link on typically a partner's site. If they publish that link with no utm params, the analytics system will recognize that traffic as referral traffic and assume it's not paid for. Now to change the channel from referral to paid, there are utm params for that marketeer to populate.

Another typical example is using the UTM parameters in emails. To help the analytics system to distinguish the direct from email channels. Otherwise all or most of email traffic will be seen as direct. Also UTMs are useful to indicate which email in particular resulted in the traffic.

As you can see, none of these examples implies any attention from front-end resources, not even mentioning the back-end.

Now you have more context about your case. You might be exceptionally requiring backend to set UTMs, but most likely it's a dire misunderstanding.

Sign up to request clarification or add additional context in comments.

6 Comments

Thanks for your answer. You are correct that 99% of websites wouldn't use backend tracking, but it is a valid option and supported by MixPanel, even including a PHP tracking library. It's working great and as expected. My query is directly related to the setting of the $direct UTM source, would Google Analytics or even MixPanel JS associate this on every page load or only on first contact? if its first contact, what would the timeframe be for resetting it? after a day? after an hour?
The fact that you have the capability to do it in the tracking library doesn't mean you should. Generally, UTMs are a session-level dimension, so only the first hit really matters. After it, you should not keep setting UTMs without a specific reason since you will be running into a chance of resetting it, which different analytics and attribution systems treat differently. You should read more documentation on UTMs in mixpanel: docs.mixpanel.com/docs/tracking/how-tos/tracking-utm-tags I don't think you're using them appropriately.
Thanks. I'm sure we are using the other UTMs appropriately, apart from $direct. Looking at that document we need to set "An initial referrer is equal to $direct when a user first lands on a site without being referred by another website. ". We aren't doing it just for the first time. I'll update my question to include this info.
For reference, here are their docs for Tracking UTMs and Referrer on the backend. docs.mixpanel.com/docs/tracking/how-tos/…. There are few major advantages of using server tracking over JS tracking, that's one of the reasons we chose this route.
Right, even for the server-side, the analytics tool is perfectly capable of processing session-level variables. You can, but don't need to set utm params more than on the first hit of the session. Still, feels wrong that you're setting utm params on the backend since it's meant to play a completely different role. Well, maybe mixpanel is weird like that. But I see nothing in their documentation implying that it needs backend setting utm params. Just pass the referrer and the full url to it and it should be good. It should be capable of parsing the utms from the url when they're there.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.