Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges

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 Reply

Avatar

Employee

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.