Customize PopUp cookies time

I would like to show the popup once per day per user. I'm not using the 'Close button acts as "Never see this message again" option, is there a way I can modify the 'po_c' cookie to a different value from the plugin instead of default 365?

  • Adam Czajczyk

    Hello Jessica

    I hope you're fine today!

    The "po_c-...." cookie is a "counter" so it's only relevant with the "Popup shown less than" rule, otherwise it's not used. The value of the cookie contains the number of times the given popup was shown to the specific user.

    To achieve what you wish, you would need to make some small changes in the plugin. First, you would want to make sure that on "PopUp -> Settings" page in "Available Conditions" section, the "PopUp Details" condition is enabled.

    Then, the popup in question should have the "PopUp shown less than" condition enabled in "Display Conditions (optional)" section of popup edit screen. Once it's enabled, set "Display PopUP this often" value for that condition to 1 (which means that popup would be shown to the user only if it was shown less than 1 time - so user didn't see it before).

    That's a prerequisite. Now, to make it work on "per day" basis instead of default "per year" you would indeed want to change the "po_c-..." cookie expiry time and that requires editing one of the plugin core files. The file to edit would be:

    /plugins/popover/js/public.min.js

    In that file you need to find this string:

    c.set_cookie("po_c",a+1,365)

    Please note: there are two places in the code (which is hardly readable because it's minified) where cookies are set so it has to be that specific one.

    Then change the 365 value in that string to 1 and that will make the expiration date of the cookie set to one day.

    Together with the condition setting (described above) in the popup settings, this would count the number of times the popup had been shown to the visitor and as a result it will show it only once. After 24 hours the cookie will expire and the cycle will repeat. As a result you should have popup shown "once per day per user".

    Please note: it's very unlikely that the JS file mentioned here will be changed anytime soon but in case of any plugin update you will have to re-apply this change in the file (fortunately, it's a "quick one"). Also, I admit I'm not sure how this would work if there are additional rules set but I assume there's none.

    I hope that helps :slight_smile:

    Best regards,
    Adam

Thank NAME, for their help.

Let NAME know exactly why they deserved these points.

Gift a custom amount of points.