donni106 / matomo-tracker-react-native

Stand alone library for using Matomo tracking in React Native and Expo projects.
MIT License
46 stars 15 forks source link

Please add method for Content Tracking #21

Open denverFAN opened 1 year ago

denverFAN commented 1 year ago

Hi @donni106

Your package is already awesome, works great. Thank you very much for developing it. It would be nice if there is a method trackContent() to track content as it is described in Matomo documentation. Many teams incl. us who installs Matomo usually use this Content Tracking feature.

Below is a brief description of the required parameters to be passed in the HTTP API request for Content Tracking.

Optional Content Tracking info

c_n — The name of the content. For instance 'Ad Foo Bar'
c_p — The actual content piece. For instance the path to an image, video, audio, any text
c_t — The target of the content. For instance the URL of a landing page
c_i — The name of the interaction with the content. For instance a 'click'

To track a content impression set c_n and optionally c_p and c_t. To track a content interaction set c_i and c_n and optionally c_p and c_t. To map an interaction to an impression make sure to set the same value for c_n and c_p. It is recommended to set a value for c_p.
donni106 commented 1 year ago

Hi @denverFAN and thank you very much.

I understand your wish. Please look into https://github.com/donni106/matomo-tracker-react-native/issues/19#issuecomment-1603904631 where I described something similar. You should be able right now to put your additional tracking params from https://developer.matomo.org/api-reference/tracking-api#optional-content-trackinghttpsmatomoorgdocscontent-tracking-info into userInfo.

In the optional userInfo param you can set any value from the API docs. So the following example should work.

trackAction({ name: 'Foo', userInfo: { c_n: 'Bar', c_p: ... } })

Please give it a try and tell us your experiences.

I can look forward to make this more clear in the documentation and will see if I can change the param name to something more generic or add multiple ones for the optional params.

denverFAN commented 1 year ago

Hi @donni106

Thank you for the quick reply and suggested solution.

Yes, I understand that, but still this is kind of a workaround. For future, it would be better if there is a separate method listed in the documentation. This will help other people incl. newbies to quickly find what they need instead of searching for a solution in Issues section. As I mentioned earlier, based on our experience this Content Tracking feature is very much frequently used. For sure this will make a package better.

Have a nice day!

donni106 commented 1 year ago

Thank you for the helpful exchange. I can understand that very well. I will make it a point to provide different methods to ensure more clarity in use.

angelxmoreno commented 10 months ago

I am unable to do this with the current TypeScript definitions because the userInfo type for the trackAction method only recognizes uid as a valid userInfo param. I started a discussion on DefinitelyTyped and the module owner, @zecergin has been pinged.

However, I really think helper methods that match each of the matomo tracking types would be absolutely amazing. I am willing to add PRs if you also see value in this @donni106 . If, in contrast, you feel like this lib should remain low-level, then perhaps an auxiliary repo that wraps this repo would be a better option.

What do you think?

donni106 commented 10 months ago

Thanks for asking, I agree with having multiple clear helper methods to make it easier to use and get started. I would love to see some contributions to share time and effort.

angelxmoreno commented 10 months ago

I came across this page on the Matomo FAQs: https://matomo.org/faq/general/what-features-of-matomo-analytics-are-supported-when-tracking-mobile-app-analytics-using-android-or-ios-sdk/

Content Tracking (content impressions and content interactions) is not yet supported in SDKs

That being said, should we even consider adding it? I can make a PR if so.

donni106 commented 10 months ago

I see good reasons to be able to track content impressions and content interactions. I even found it documented in the iOS SDK: https://github.com/matomo-org/matomo-sdk-ios#content-tracking The info on the other page seems outdated.

angelxmoreno commented 10 months ago

@donni106 how do you feel about Typescript and how do you feel about converting the tracker into TS? There are a few features I'd love to make a PRs for but I wouldn't be able to use those features in my project. This is because the typed-definitions donated at DefinitelyTyped would be outdated.

donni106 commented 9 months ago

As we have a few mentions now regarding disadvantages according to not have TS, we should aim for converting the code base. It should be a manageable effort overall. @73k05 would you be available for helping out here, as it would serve for #20?

73k05 commented 8 months ago

Hey @donni106 moving to TS is always a good idea 🎄 I'm down to review the PR or help in a specific task, let me know how I can help 🙂