Comments (5)
This issue is really old, but I just butted my head on it so I'll write here the solution for anyone looking.
The docs are a bit misleading, but looking at the code here the uid needs to be passed in the options object to work. Alternatively you can use the persistent parameters.
from universal-analytics.
I am also looking into this. It looks like the second param is only the cid
which isn't the same as User-ID
/uid
.
@theoephraim did create #35 that addresses #34 for the same issue.
from universal-analytics.
Thanks for the heads-up, just updated to docs.
from universal-analytics.
Same problem still going on now
I am running on express and using this middleware function I wrote for all routes
const analyticsMiddleware = (req, res, next) => {
const userId = req && req.user && req.user._id ? req.user._id : req.visitor.cid
var visitor = ua(process.env.GOOGLE_ANAYTICS_TRACKING_ID, userId, { strictCidFormat: false});
console.log(req.visitor.cid, req && req.user ? req.user._id : '', visitor);
visitor.pageview(req.path).send();
next();
}
Always has the incorrect cid , my custom userId from the database looks like this 5d52a69b062d1a150b345712
It is definitely not a UUID but isnt that strictCidFormat supposed to handle this case
If I call visitor.set('uid', '5d52a69b062d1a150b345712') as @mdenti mentioned I get an error saying invalid UUID format
Any ideas?
from universal-analytics.
Update never mind,
I think this works
const analyticsMiddleware = (req, res, next) => {
const userId = req && req.user && req.user._id ? req.user._id : req.visitor.cid
req.visitor.set("uid", userId);
req.visitor.pageview(req.path).send();
next();
}
from universal-analytics.
Related Issues (20)
- Ad tracking? HOT 1
- Vulnerability in "request" sub-package HOT 6
- Typescript support? HOT 1
- How to mark event as "User" (raising login event won't mark thing as user) HOT 1
- Custom dimensions with E-commerce tracking HOT 1
- GA + UA HOT 2
- 'Cannot read properties of undefined (reading '_readableState')' error occurred after 0.5.0 update HOT 2
- Payload data sent as object not working HOT 2
- IP not being assigned when using a proxy HOT 2
- Requests are being ignored by GA HOT 5
- Support for Event Values as String HOT 4
- Analytics no longer sent since upgrade from 0.4.23
- Transaction is not reflected being reflected on GA dashboard HOT 2
- Transactions are not being reflected on GA dashboard HOT 3
- Custom dimension and Event data not matching
- Universal Analytics Deprecation HOT 3
- Active users count differently with and without `strictCidFormat`
- Yarn problem with WebpackEncore
- Separate License file?
- Using HTTP proxy
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from universal-analytics.