Need to show banner/teaser once per session using Profile script in Adobe Target. | Community
Skip to main content
New Participant
October 29, 2024
Solved

Need to show banner/teaser once per session using Profile script in Adobe Target.

  • October 29, 2024
  • 1 reply
  • 1965 views

Hi Team,

 

I have a requirement to display a banner/teaser once per session using a Profile Script in Adobe Target. This functionality is needed for multiple use cases.

Could you please provide guidance on how to implement this across the various use cases?

Thank you!

 

Best regards,
Devakrishna R S V

Best answer by kandersen-1

@devakrishnara2  Sorry, try this instead - i was a bit too quick on the previous one:

// Profile script to control session-only display of a banner if (user.sessionId != user.getLocal('sessionIdBannerShown')) { // First time in this session, allow the banner to display user.setLocal('sessionIdBannerShown', user.sessionId); return false; // Indicates banner can be shown } else { // Banner has been shown already in this session return true; // Indicates banner should not be shown again }


Here's a quick demo of it in action: https://www.loom.com/share/db450c90641c4e8fa940b535b28a87f1?sid=32e84a1b-1beb-498e-a929-b3c33e06ed30 

1 reply

kandersen-1
New Participant
October 29, 2024

Hi @devakrishnara2 

 

I think it should something like this:

// Profile script to control session-only display of a banner if (user.sessionId !== profile.sessionIdBannerShown) { // First time in this session, allow the banner to display profile.sessionIdBannerShown = user.sessionId; return false; // Indicates banner can be shown } else { // Banner has been shown already in this session return true; // Indicates banner should not be shown again }

Please note, that i haven't tested it. 

In order to implement it, step 1) is to create the profile script. Step 2) is to create an audience which looks at the profile script (find it under visitor profile) and set it to contain/equal false. Step 3) apply this audience to your activity.

An alternative approach could be controlling it inside the experience by using a script and sessionStorage. You would apply this as custom code in the experience and you would then have to inject the banner as part of the script:

// Custom script to run in Adobe Target if (!sessionStorage.getItem("bannerShown")) { // Display the banner and set a flag document.getElementById("your-banner-id").style.display = "block"; sessionStorage.setItem("bannerShown", "true"); } else { // Hide the banner if already shown document.getElementById("your-banner-id").style.display = "none"; }

 

Probably not optimal as you won't be able to exclude on audience level, but wanted to mention it anyway.

I share weekly Adobe tips on LinkedIn—connect with me!Every Wednesday: "Something a client recently asked..."LinkedIn Profile
New Participant
October 30, 2024

Thank you @kandersen-1 ,

 

I tried the above code but it's not working any other suggestions, for implementing the scenario using profile scripts?

 

Note: we have integrated Target using WebSDK.

 

Regards,

Devakrishna R S V

 

kandersen-1
kandersen-1Accepted solution
New Participant
October 31, 2024

@devakrishnara2  Sorry, try this instead - i was a bit too quick on the previous one:

// Profile script to control session-only display of a banner if (user.sessionId != user.getLocal('sessionIdBannerShown')) { // First time in this session, allow the banner to display user.setLocal('sessionIdBannerShown', user.sessionId); return false; // Indicates banner can be shown } else { // Banner has been shown already in this session return true; // Indicates banner should not be shown again }


Here's a quick demo of it in action: https://www.loom.com/share/db450c90641c4e8fa940b535b28a87f1?sid=32e84a1b-1beb-498e-a929-b3c33e06ed30 

I share weekly Adobe tips on LinkedIn—connect with me!Every Wednesday: "Something a client recently asked..."LinkedIn Profile