I have a client with a Salesforce Community website who wants to have a pop-up on the homepage, but they only want it to pop up one time per user. This is before they login, so I'm thinking what I'd need to do is drop a cookie on their computer so I know that they already saw the pop-up. Is this possible? Does anyone have any better ideas to make this happen? Thanks!

  • once per visit/session? once in a lifetime?
    – glls
    Apr 17 '19 at 15:52

Yes, you can use either document.cookie or window.localStorage to remember this sort of information.

Edit: To explain further, you'd create a custom component, and place it within your community somewhere. This component would check to see if the notification has already been displayed (via cookie or a key in storage), and if not, display a modal and set the flag so future visits won't trigger the modal.

  • But how will you access/set these when the Community login page loads? One approach I could think of is to embed a VF page/lightning component on the Community Login page and upon initialization set/access the cookies. Is that what you are recommending?
    – Jayant Das
    Apr 17 '19 at 16:26
  • @JayantDas Yes, you'd need a way to display the modal anyways, so a Lightning Component would be ideal here. It can just check if there's a cookie/key, if not, display the message and set the cookie/key.
    – sfdcfox
    Apr 17 '19 at 16:48
  • 1
    Yep I had thought the same, I think it will be good to add that information here in your answer to detail out a bit?
    – Jayant Das
    Apr 17 '19 at 16:49
  • @JayantDas Fair enough. Edited.
    – sfdcfox
    Apr 17 '19 at 16:55
  • Thanks :) +1 for detailing it out.
    – Jayant Das
    Apr 17 '19 at 16:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.