Skip to main content
TimBo4
Level 2
Nov 3, 2026 3:37 PM UTC
Question

Profile Scripts

We are not utilizing profile scrips and want to understand if there are certain fundamental profiles scrips that we should consider? Would love to know what are some basic scripts that have great utility that others are using!

    2 replies

    Gokul_Agiwal
    Community Advisor
    Community Advisor
    Nov 3, 2026 3:47 PM UTC

    Hi ​@TimBo4 

    Profile scripts to capture visitor attributes across multiple visits. Profile scripts are code snippets defined within Target using a form of server-side JavaScript. For example, you might use a profile script to capture how frequently a visitor visits your site, and when that visitor last visited 

     

    Here are some common script examples that you can use based on your use cases. 

     

    In case if you’re looking for specific profile script for your specific use case, or script based on the websdk please let us know. 

    Hope this helps. 

    Thank you. 

    Translate
    Thanks, Gokul
    Isha Gupta
    Adobe Champion, Community Advisor, UG Leader
    Adobe Champion, Community Advisor, UG Leader
    Nov 20, 2026 5:40 PM UTC

    Hey ​@TimBo4 ,

    I have used profile scripts in past for different organization. In my current one, we are starting to explore possible use cases as well. Some use cases that we are actively looking at are below-

    1. Engagement Score - Assign a score to user based on their web behaviour like viewed a page, clicked on CTA etc. and then show experience in accordance with user’s engagement. We can utilize Experience targeting for this.
    2. Visit Number - As ​@Gokul_Agiwal mentioned, Arun has a great resource of ready to use profile scripts like Visit number where you show experience based on user’s visits.
    3. Time Spent - Based on time spent on page, you can increment the counter and show a experience. For example, if user is on cart pages, user does not convert, show a pop up or something for accessing help documents. Sample profile script below.

    try {
        var key = "pageStartTime_" + window.location.pathname;
        
        var startTime = sessionStorage.getItem(key);
        
        if (!startTime) {
            startTime = new Date().getTime();
            sessionStorage.setItem(key, startTime);
            return 0;
        }

        var currentTime = new Date().getTime();
        var timeSpentSeconds = Math.floor((currentTime - startTime) / 1000);

        return timeSpentSeconds;

    } catch (e) {
        return 0; //
    }

     

    Hope this helps!

    Translate