I am setting up an affiliate link area for my site and need to be able to store a URL query string into a cookie that expires in a 7 days.
Users will click on a link like: http://examplesite.com?afil=randomvalue.
I want to pull the key 'afil' and the value 'randomvalue' and put it in a cookie in the browser.
This cookie will be used later (on another page) in a link from one of examplesite.com to order.examplesite.com but I can't keep the parameter (query string) in the URL.
I asked this last week and got an answer for using PHP: Add URL Parameter to Cookie
The problem is that I am using HubSpot and they don't allow me to use PHP code on the site.
I am hoping that they do permit Javascript or JQuery... so my questions are:
- How can I set a cookie from the URL query string using Javascript or JQuery?
- How can I call the value of said cookie to appear in a link using Javascript or JQuery?
I am hoping to find something similar to what they were trying to do here but this issue was never resolved: Set and check Javascript cookie based on url query string