stape-io / gtm-server-side-wordpress-plugin

Google Tag Manager Server-Side plugin for WordPress
https://stape.io/how-to-add-google-tag-manager-server-side-container-to-wordpress/
GNU General Public License v2.0
15 stars 2 forks source link

Client side option for setting Cookie Keeper cookie #10

Closed roborourke closed 1 month ago

roborourke commented 1 month ago

Hi, on some hosts the page cache / CDN is configured such that only a specific list of cookies are allowed to be forwarded to the server in order to keep a high cache hit rate.

Would it be possible to support setting the cookie keeper cookie in JavaScript instead of via PHP? Seems like it shouldn't matter if it's not HTTP only. Or would be good to at least provide client side as an option instead.

vladkononov commented 1 month ago

Hi, No, JS cookie won't work as a master cookie, as it is not persistent for Safari and will be removed after 7 days of browser usage (please refer to Safari 16.4 updates). The whole idea behind master cookie is that it must be persistent and to achieve this - it has to be set by the server behind the website.

roborourke commented 1 month ago

@vladkononov ah right. I guess we can’t use this feature in that case 🤔 I’ll have a think. Maybe it can be set by making a client side request to an API endpoint that returns a no-cache header while setting the cookie?

vladkononov commented 1 month ago

@roborourke you may use Cookie Keeper with your custom master cookie. In Stape admin you may generate GTM loader with Cookie Keeper that uses your master cookie to restore other cookies. You just need to specify the name of your custom master cookie, generate the loader and paste it manually on your website without the plugin.

roborourke commented 1 month ago

I was able to implement this method of proxying through nginx to solve the issue, so I think Cookie Keeper won't be needed now if Im understanding this post correctly https://stape.io/news/a-new-way-to-set-up-a-custom-domain-in-server-gtm

Closing this out.