Giter VIP home page Giter VIP logo

Comments (17)

kris7ian avatar kris7ian commented on July 26, 2024 1

@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.

chrisvanmook avatar chrisvanmook commented on July 26, 2024 1

@chriggi thanks for the clear explanation. I think this is something to take into account when working on issue #176

from matomo-tracker.

lgp171188 avatar lgp171188 commented on July 26, 2024 1

@jonkoops, this is great news! Thanks for acting and responding very quickly! 👍🏼

from matomo-tracker.

lgp171188 avatar lgp171188 commented on July 26, 2024 1

@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.

chrisvanmook avatar chrisvanmook commented on July 26, 2024

@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.

ramaHruday avatar ramaHruday commented on July 26, 2024

_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.

chrisvanmook avatar chrisvanmook commented on July 26, 2024

@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):

Hope this helps

from matomo-tracker.

chrisvanmook avatar chrisvanmook commented on July 26, 2024

@ramaHruday Is this issue still relevant? Otherwise will close it.

from matomo-tracker.

kris7ian avatar kris7ian commented on July 26, 2024

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.

chrisvanmook avatar chrisvanmook commented on July 26, 2024

@chriggi @ramaHruday This is fixed in version v0.1.5

from matomo-tracker.

CoenWarmer avatar CoenWarmer commented on July 26, 2024

This would be very nice to have :)

from matomo-tracker.

jonkoops avatar jonkoops commented on July 26, 2024

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.

lgp171188 avatar lgp171188 commented on July 26, 2024

@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.

jonkoops avatar jonkoops commented on July 26, 2024

@lgp171188 We just released v0.2.0 which includes this change.

from matomo-tracker.

lgp171188 avatar lgp171188 commented on July 26, 2024

(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.

jonkoops avatar jonkoops commented on July 26, 2024

@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.

jonkoops avatar jonkoops commented on July 26, 2024

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)

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.