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.