Expand my Community achievements bar.

SOLVED

Profile Script for inactivty on 15sec on web page

Avatar

Level 2

Hi,

I need to show some banners after user inactivty of 15 sec on web page, I written JS code which is running on console but giving an error as "Invalid user input" on Target's profile script.

 

var time;
document.onload = resetTimer;
document.onmousemove = resetTimer;
document.onmousedown = resetTimer; // touchscreen presses
document.ontouchstart = resetTimer;

document.onclick = resetTimer; // touchpad clicks
function popup()
{return true; }
function resetTimer() {
clearTimeout(time);
time = setTimeout(popup, 15000);
}

 

can someone please guide me how I can use this as profile script? so based on this audience can be created.

 

@LJ_Jones  @ParitMittal @nickh86417692 @Løjmann 

1 Accepted Solution

Avatar

Correct answer by
Employee Advisor

Hi @RudraChaudhari - Profile Scripts leverage JS Rhino and function differently than client side executed javascript.   For your use case, it would probably be better to deliver the javascript through a Target offer either using the VEC (Custom Code) or the Form Based composer.   For reference, we also have some sample templates including one for a modal on a timer which can be viewed here.  Try delivering it through an activity to the page rather than using Profile Scripts which are executed server side on Target's servers.  

View solution in original post

1 Reply

Avatar

Correct answer by
Employee Advisor

Hi @RudraChaudhari - Profile Scripts leverage JS Rhino and function differently than client side executed javascript.   For your use case, it would probably be better to deliver the javascript through a Target offer either using the VEC (Custom Code) or the Form Based composer.   For reference, we also have some sample templates including one for a modal on a timer which can be viewed here.  Try delivering it through an activity to the page rather than using Profile Scripts which are executed server side on Target's servers.