Take the 2-minute tour ×
Server Fault is a question and answer site for system and network administrators. It's 100% free, no registration required.

Im setting up varnish on my server and have been studying the VCL ( which I think is very neat ) and I have the following in the vcl_recv I am writing which I don't understand why it would be necessary.

if (req.url ~ “\?(utm_(campaign|medium|source|term)|adParams|client|cx|eid|fbid|feed|ref(id|src)?|v(er|iew))=”) {
    set req.url = regsub(req.url, “\?.*$”, “”);
}

This is stripping the google analytics tracking off the GIF request to google.

Why would this be necessary to strip from the request coming in to my server, and wouldn't this destroy the tracking and analytics of my clients?

share|improve this question

1 Answer 1

This is not stripping any cookie, but rather regsubing a lot of uri extensions/parameters (like ver=somethingsomething). Personally I think that if you didn't intentionally write this, then don't use it.

Regarding the question about what impact removing the google __utm* cookies will have on analytics then. You link to some external js script, client fetches it and google issues a Set-Cookie that matches your domain. Next request the user does to YOU contains this Cookie, and thus prevents you from using an user independent cache. Thus, you remove this cookie on YOUR side. Google analytics is not affected as the google .js you serve is not able to read the headers on server side, but rather on client side, so in other words they have no function for your site. Analytics got their information when the client requested the .js file. You should obviously not issue any cookies with conflicting names as that could potentially cause problems.

I basically use the example on varnish-cache.org:

if (req.http.Cookie) {
    set req.http.Cookie = regsuball(req.http.Cookie, "(^|; ) *__utm.=[^;]+;? *", "\1"); #     removes all cookies named __utm? (utma, utmb...) - tracking thing

    if (req.http.Cookie == "") {
        remove req.http.Cookie;
    }
}
share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.