Score:0

Is there a way to write the query parameters as cookie in nginx

us flag

I would like to ask if there's a way to set the query parameters as the cookie of a certain url?

Currently i'm having trouble with the varnish and nginx cause it was stripping the utm params which causes an issue with the GA. I can't remove the code that strip utm params since it would flood the varnish cache. So I was thinking of getting the utm params and set it as cookie from the nginx config

Any help would be appreciated

Thank you so much

Score:0
cn flag

You can easily remove Google marketing URL parameters from URL that Varnish fetches from backend, like described here:

if (req.url ~ "(\?|&)(gclid|utm_[a-z]+)=") {
    set req.url = regsuball(req.url, "(gclid|utm_[a-z]+)=[-_A-z0-9+()%.]+&?", "");
    # remove trailing question mark and ampersand from URL
    set req.url = regsub(req.url, "[?|&]+$", "");
}

This must be implemented in the vcl_recv routine of Varnish configuration. In this way, the URL that you see stays intact in the browser (which is important for Google Analytics), but Varnish will request and cache based on normalized URL without those parameters (for backend, e.g. PHP those parameters can be discarded).

mangohost

Post an answer

Most people don’t grasp that asking a lot of questions unlocks learning and improves interpersonal bonding. In Alison’s studies, for example, though people could accurately recall how many questions had been asked in their conversations, they didn’t intuit the link between questions and liking. Across four studies, in which participants were engaged in conversations themselves or read transcripts of others’ conversations, people tended not to realize that question asking would influence—or had influenced—the level of amity between the conversationalists.