Mixpanel Community Icon

Understanding $referrer Behavior in $session_start Events

·
·

Why is $referrer sometimes the same as the current page URL in $session_start events? I'm analyzing $session_start events and noticed that the $referrer property sometimes matches the current page's URL (the page the event is triggered on). My understanding is that $referrer should capture the URL of the previous page before landing on the current one. Could this behavior be caused by redirects, browser behavior, or Mixpanel's tracking logic?

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Hi Eliott C., Please stand by as I search the Mixpanel knowledge base for an AI-powered answer. I normally take about 15 seconds or so. In case AI cannot answer your question, feel free to reach out to Mixpanel support at mixpanel.com/get-support. If you have follow-up questions for this thread, please tag me again with your question: @kapa.ai <follow-up question> đź‘‹

    Feel free to ask a follow-up question once I've answered by mentioning me with @kapa.ai

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Based on the knowledge sources provided, there isn't specific information addressing why the session_start events. However, I can provide some general insights about how Mixpanel tracks referrer information that might help explain this behavior.The referrer to match the current page URL:1. Single Page Applications (SPAs): If your website is a SPA, navigation between "pages" might not trigger a full page reload. This could potentially cause the referrer might be set to the current page URL.3. Direct Navigation: As mentioned in the Default Properties documentation, when a user lands directly on a page (e.g., by typing the URL, using a bookmark, or clicking a link from an email), the referrer property.It's worth noting that Mixpanel distinguishes between initial_referrer. The referrer can change with each page view.If you're seeing unexpected behavior with the referrer property in server-side implementations.For a more definitive answer about why you're seeing this specific behavior, you might need to reach out to Mixpanel's support team with details about your implementation and examples of the unexpected behavior you're observing.

    kapa.ai is still learning and improving, please let me know how I did by reacting below.

    ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.

  • Avatar of Eliott C.
    Eliott C.
    ·
    ·

    kapa.ai When multiple events (e.g., Page View, API Call, server-side events) are triggered at the start of a session, but they don’t follow a fixed order, how can I determine which event best represents the "session start"? I also want to ensure I can track the referral path (e.g., $referrer, $initial_referrer, or UTM parameters) from that event. What’s the best way to identify the primary session start event in this scenario?

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Let me check the knowledge base for you again. One moment! đź“š

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    To address your question about determining the best event to represent the "session start" when multiple events are triggered without a fixed order, and ensuring you can track the referral path, I'll provide some insights based on the available knowledge sources. 1. Session Start Event: Mixpanel automatically computes sessions based on your existing event data. According to the [Sessions documentation](https://docs.mixpanel.com/docs/features/sessions), there are three ways to configure how sessions are computed: a) Timeout Based (Default): The session starts when a user performs any event and ends after a period of inactivity. b) Event Based: You define specific starting and ending events. c) Property Based: You provide a session_id property. In your case, where multiple events are triggered at the start of a session without a fixed order, the Timeout Based method might be the most suitable. This way, Mixpanel will automatically determine the session start based on the first event that occurs after a period of inactivity. 2. Tracking Referral Path: To ensure you can track the referral path, you should focus on capturing the relevant properties on the client-side, preferably using Mixpanel's JavaScript SDK. Here's why: a) The [Web Attribution documentation](https://docs.mixpanel.com/docs/tracking-best-practices/traffic-attribution#web-attribution) states that Mixpanel's JavaScript library automatically tracks UTM parameters and referrer information. b) Specifically, it captures: - $initial_referrer and $initial_referring_domain: These are stored in the Mixpanel cookie on the user's first visit and sent with all future events. - $referrer and $referring_domain: These are captured for each page view. - UTM parameters: All UTM tags are tracked by default. c) The [Initial Referrer and Initial Referring Domain Properties documentation](https://docs.mixpanel.com/docs/tracking-best-practices/traffic-attribution#initial-referrer-and-initial-referring-domain-properties) confirms that these properties are appended to any event that a user completes. To implement this approach: 1. Ensure you're using Mixpanel's JavaScript SDK on your website. 2. The SDK will automatically capture referrer and UTM information on the client-side. 3. For server-side events, you can use the mixpanel.get_session_recording_properties() method to get the relevant Session Replay properties, which include the $mp_replay_id. This ID can help link server-side events to the correct session. [Session Replay documentation](https://docs.mixpanel.com/docs/session-replay/session-replay-web#why-cant-i-view-replays-from-my-insights-or-funnels-chart)

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    4. If you're using server-side tracking, you can implement server-side attribution as shown in the Server-Side Attribution documentation. This ensures that UTM parameters and referrer information are extracted from the request and added to your server-side events.By following these steps, you'll capture the referral path information on the client-side, which will be associated with the automatically determined session start event. This approach allows you to track the referral path regardless of which specific event ends up being the first in the session.Remember, you can always analyze your sessions data in Mixpanel to identify patterns and determine which events are most commonly occurring at the start of sessions, giving you insights into your users' typical session start behaviors.

    kapa.ai is still learning and improving, please let me know how I did by reacting below.

    ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.

  • Avatar of Eliott C.
    Eliott C.
    ·
    ·

    kapa.ai why sometimes $referrer is set as $other?

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    Let me check the knowledge base for you again. One moment! đź“š

  • Avatar of kapa.ai
    kapa.ai
    APP
    ·
    ·

    I apologize, but after carefully reviewing the provided knowledge sources, I couldn't find any specific information about why the other" in Mixpanel. The knowledge sources don't contain enough information to directly answer this question.However, I can provide some general context about the referrer property is typically used to capture the URL of the page that referred the user to the current page. This is mentioned in the Default Properties documentation.2. For web tracking, Mixpanel's JavaScript library automatically captures referrer information, as stated in the Web Attribution documentation.3. In some cases, the referrer might not be available. For example, when a user lands directly on a page (by typing the URL, using a bookmark, or clicking a link from an email), the referrer might not be set.The "referrer property is not explicitly mentioned in the provided knowledge sources. It's possible that Mixpanel uses this as a default or fallback value in certain situations, but without more specific documentation, I can't confirm why or when this occurs.To get a definitive answer about why other", you would need to consult Mixpanel's support team or look for more detailed documentation that isn't included in the provided knowledge sources.

    kapa.ai is still learning and improving, please let me know how I did by reacting below.

    ℹ️ Tip: Mention @kapa.ai in the thread for follow-ups or DM the app for 1-to-1 help.