App start with pop-up frame if GDPR is not acceptded

Hi
I'm a new beginner and I have low knowledge about coding and javascript.

I need help with a script to show a modal if "Get_GDPR === false" when user open a APP.

How can this be done and where shall I putt a script in ReTool?

Thanks in advance for your help.

-Thore

Hi @Thore,

You can get something like this going by adding a modal component, then leveraging localStorage and the hidden property on the modal. Here's an example.

Step 1: Add the modal component
image

Step 2: Add content and a button to your modal

Step 3: Add an event handler to your button, that sets a localStorage value to true. I added an app identifier to the variable name in case you need to leverage this across apps.
image

Step 4: Configure the hidden property on the modal so it is hidden after a user has accepted. With the modal selected...
image
{{localStorage?.values?.myapp_Get_GDPR === true}}

This will show the modal initially, and on subsequent visits if they haven't clicked accept. If you want more control / enforcement, you can remove the "X" close button from the header, add a second button for reject (and redirect them somewhere else) etc.

1 Like

Hi

I added a modal
image

I added a button etc. When I open the App, the modal did not pop-up.

Is there something I'm doing wrong or is there something missing when stating the App?

You will probably need to make a query that runs on page load and triggers GDPR.show()

Hi @Thore,

Can you share screenshots of your modal setup (the hidden property specifically) as well as the event handler on your button and it's code?

By having this code: {{localStorage?.values?.myapp_Get_GDPR === true}} in your modal's hidden property, it should be visible by default for anyone who hasn't clicked the button. The ?'s in the code prevent it from throwing an error if the value doesn't exist at all, so unless the value exists AND it's true, the modal should not be hidden. I tested this in an app of mine and it behaved as expected, so if you can share the code/sections mentioned above, we can see what's going on.

It looks like i forgot this on the modal.

It works as expected and thank you for your help.

2 Likes