Coder Social home page Coder Social logo

Comments (2)

sandromartis avatar sandromartis commented on June 30, 2024

Hey

I just tested that and I think you're right.

If

app.use(ua.middleware(config.ga.key, {
  cookieName: '_ga'
}));

is BEFORE app.use(cookieParser()) then Universal Analytics does not seem to find the cid that is stored in the cookie and it creates a new one (something in the form of 53816753-23f6-4839-8eed-c99bd6bf33d6).

But if Universal Analytics is AFTER cookieParser then the cid is the same as in the cookie that is stored in the browser (something like 2114748171.1452681493).

I'm not sure if this is a bug of Universal Analytics or intended behaviour. Of course it makes sense that cookies only work properly if cookieParser() is before Universal Analytics. The format 53816753-23f6-4839-8eed-c99bd6bf33d6 still looks odd though.

Anyway, what I noticed is that I had a lot of (not set) values in my Google Analytics Dashboard and now that I looked at it again, I realized, that I actually had the Universal Analytics code BEFORE the cookieParser() in my Express.js config. (Like you described)
So I guess a new cid was generated every time I sent a custom tracking event. Thus Google Analytics was not able to match the back-end cid to the font-end cid resulting in (not set) values.

Is this assumption correct? Can somebody confirms this?

Best,
Sandro

from universal-analytics.

mebibou avatar mebibou commented on June 30, 2024

@sandromartis yes, middlewares are used in the order they are defined in your code, if cookieParser is used after then it only parses the cookies after this middleware. Order of use is important for every middleware, nothing to do with this one.

I guess it would be worth mentioning in the README

from universal-analytics.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.