Mixpanel Community Icon

How to check in mixpanel the last content viewed by the user

·
·

How to check in mixpanel the last content viewed by the user

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

    Hi Sonia, 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
    ·
    ·

    To check the last content viewed by a user in Mixpanel, you can utilize the "last-touch" UTM tracking approach. This method allows you to track the most recent content or page a user has viewed. Here's how you can implement it:1. First, you need to set up last-touch UTM tracking in your Mixpanel implementation. This can be done by adding custom code to your website that captures and updates UTM parameters with each page view.2. You can use the following JavaScript code snippet to implement last-touch UTM tracking:LBKS// Paste the following code below the Mixpanel Javascript Snippet // that you add to your site to track events.LBKSfunction getQueryParam(url, param) { // Expects a raw URL param = param.replace(/[[]/, "\[").replace(/[]]/, "\]");LBKS var regexS = "[\?&amp;]" + param + "=([^&amp;#]*)", regex = new RegExp( regexS ), results = regex.exec(url);LBKS if (results === null || (results &amp;&amp; typeof(results[1]) !== 'string' &amp;&amp; results[1].length)) { return ''; } else { return decodeURIComponent(results[1]).replace(/\W/gi, ' '); } };LBKSfunction campaignParams() { var campaign_keywords = 'utm_source utm_medium utm_campaign utm_content utm_term'.split(' ') , kw = '' , last_params = {} , first_params = {};LBKS var index;LBKS for (index = 0; index < campaign_keywords.length; ++index) { kw = getQueryParam(document.URL, campaign_keywords[index]); if (kw.length) { last_params[campaign_keywords[index] + ' [last touch]'] = kw; } }LBKS // Add more code here to handle first-touch params if needed }LBKS<https://docs.mixpanel.com/docs/tracking-best-practices/traffic-attribution#last-touch-utm-tracking|Traffic Attribution>3. Once you've implemented last-touch UTM tracking, Mixpanel will store the most recent UTM parameters for each user as profile properties and super properties.4. To view the last content viewed by a user, you can look at the user's profile in Mixpanel. The last-touch UTM parameters will show the most recent content or page the user has visited.5. You can also create reports or segments based on these last-touch UTM properties to analyze user behavior and content engagement.Remember that this method relies on UTM parameters, so you'll need to ensure your content pages have appropriate UTM tags for accurate tracking.If you need more detailed information about viewing user profiles or creating reports based on these properties, you may need to consult additional Mixpanel documentation.

    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.