Comments (17)
@chrisvanmook unfortunately it's not fixed yet. While you can set a userId on initialization, I can't set it programmatically (via _paq.push(['setUserId', 'USER_ID_HERE']);
, see my link above). I don't have the userId yet on initialization as it is stored in the redux store, and it might only be available after login.
Ideally we could have a function similar to trackPageView
named setUserId
which sets the userId after initialization.
Thanks
PS: can this issue be reopened for others to see? I saw someone else opened a similar issue which was closed because of insufficient description.
from matomo-tracker.
@chriggi thanks for the clear explanation. I think this is something to take into account when working on issue #176
from matomo-tracker.
@jonkoops, this is great news! Thanks for acting and responding very quickly! 👍🏼
from matomo-tracker.
@jonkoops, thanks for the very quick response and creating+merging #242. I have created a documentation PR #243 mentioning the functions exposed by the useMatomo()
hook and also an example for using the pushInstructions()
function. 👍🏼
Since this is a monorepo with both the JS and React versions of the library, there is no easy way to install the master branch and hence it will be great if you can tag a new release once all the changes planned for that release are merged and ready. Thanks again! 🙂
from matomo-tracker.
@ramHruday I'm not sure what you want to do... Could you explain in detail / give an example what do you want to accomplish?
from matomo-tracker.
_paq.push(['setUserId', 'USER_ID_HERE']);
_paq.push(['trackPageView']);
i actually want to set the userid..after he logs in my application
thanks for immediate response
from matomo-tracker.
@ramaHruday Unfortunately it's still too insufficient info... Which package are you using (react or js?) I strongly suggest you take a look at the documentation on how to track events and page views, as we use different methods to call them (unlike your example with _paq
):
- js: https://github.com/Amsterdam/matomo-tracker/tree/master/packages/js
- react: https://github.com/Amsterdam/matomo-tracker/tree/master/packages/react
Hope this helps
from matomo-tracker.
@ramaHruday Is this issue still relevant? Otherwise will close it.
from matomo-tracker.
Can this be reopened? I'm looking for this too. More info can be found on matomo's homepage: https://developer.matomo.org/guides/tracking-javascript-guide#user-id
from matomo-tracker.
@chriggi @ramaHruday This is fixed in version v0.1.5
from matomo-tracker.
This would be very nice to have :)
from matomo-tracker.
This should now be possible on master
by calling pushInstruction as follows:
const tracker = new MatomoTracker({ ... })
tracker.pushInstruction('setUserId', 'USER_ID_HERE')
from matomo-tracker.
@jonkoops, since the fix for this issue is on the master
branch and not in a tagged release, can you create a new tagged release so that it is possible to make use of this feature? Thank you!
from matomo-tracker.
@lgp171188 We just released v0.2.0
which includes this change.
from matomo-tracker.
(this issue is probably not the right place to ask this question, but can't find a better place)
@jonkoops, the usage instructions that you have shared are not clear about how one could use the pushInstruction
method from a React component under the MatomoProvider
component tree. For instance, the useMatomo
function doesn't return the pushInstruction
method of the instance
here. Should one create an instance manually by
const instance = React.useContext(MatomoContext);
to get the already created instance?
If yes, I'd like to submit a documentation PR mentioning this. If not, would it be okay to expose the pushInstruction
method in via the useMatomo
function? I can submit a PR for that as well.
from matomo-tracker.
@lgp171188 Yeah, I am not happy with how the React context works here. We're thinking about changing this API in the future.
I've created #242 to export the method in the useMatomo
hook as well. If you want to open up a PR for documentation that is of course always welcome 👍
from matomo-tracker.
Thanks @lgp171188, it's much appreciated. If you want to use that package locally I would recommend building the project locally, buidling it and use yarn link
or npm link
to link the package to your project.
Regardless of this we will publish a new version that includes this fix soon.
from matomo-tracker.
Related Issues (20)
- Multiple Matomo instances
- Multiple tracker objects HOT 1
- Missing ecommerce actions
- Why different param names? HOT 3
- Missing ecommerce getter
- Missing callback support
- Is there any way to globally set a custom dimension value? HOT 3
- Refresh or reset React context instance to track logged users HOT 2
- Module Warning & Failed to parse source map error when used with Create React App v5.0.0 with Typescript HOT 6
- pushInstriction type mismatch. Could reuse MatomoInstance interface
- Publish new package HOT 15
- matomo-react bad idea to call window._paq manually? HOT 1
- Update to support react v18 HOT 1
- Fingerprintjs and FormAnalytics
- can you create a new release version in github ? HOT 1
- Integration of Matomo Tag Manager HOT 1
- Unable to build React project with Matomo as dependency
- Multiple npm packages for matomo-tracker-react
- matomo.js script won't be loaded anymore HOT 2
- Pod is not working in m1 chip system
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 matomo-tracker.