How can we generate `_id` for logged in user in matomo(piwik) http API tracking - matomo

Short version:
In matomo JS tracking, we only need to set userId for logged-in user, matomo will take care of the other parameters like _id(which is used to identify the user). However, if I use http API to track the user, I do not have _id, matomo is not able to identify the request is from the same user if I only set uid. So how can I get/query/calculate the _id value for any userId?
Full story:
This issue is raised when I use both JS and http API to track the same site, the reason is that the shopping cart tracking is hard to be done in frontend, so we decided to track it at backend and make use of matomo's http API. It works correctly when only JS client is used. For example in shopping cart tracking, matomo correctly records the revenue left in the cart even if I do a series of shopping cart add/edit/remove. But when I track the same thing using http API, the revenue left in the cart is wrong, all requests are treated as from different users. Let me give a simple example.
Add $10 in cart
Clear cart
Add $20 in cart
JS client gives revenue left in cart to be: $20 (correct)
Http tracking gives revenue left in cart to be :$30 (wrong, since matomo thinks the two add events are from different user)
I've tried to use postman to poke around and found that the actual cause is the _id field. If I set it to the same value and perform the above actions. Revenue calculation is correct. So how can I set the _id value so the same user has same _id in both JS tracking and http tracking?

Related

Tracking visitors who visited website with a code in url with Google Analytics

I have a React website, I want to build a system that first a code is created for example its "my-special-code-100". I want to track website visitors who entered the website from a url like https://mywebsite.com/../?code=my-special-code-100 and need to track if or if not X 'not signed in' visitor do a successful payment - a button click on specific page - also need to store an account id of the wallet, payment that happened, and need to see trackings of how many visitors of website came with "my-special-code-100"(and other codes) and how many of them made a payment and stored wallet id should be visible for that visited user.
I couldn't be sure how to and is Google Analytics correct tool for this and could you give example what can I use to achieve something like this ? Thanks

How to finalise one-time payment summary with Firebase Extension "Run Payments with Stripe" on a ReactJs website

I'm currently using Firebase for my ReactJs website.
I wanted to use stripe to add a payment module. So I created an account on Stripe and added the extension "Run Payments with Stripe" on my Firebase project.
Everything works fine on this extension on my website:
I can make payment
I'm well redirected to the Stripe payment interface
The webhook add the payment document on my customer document on Firestore
But, I have one problem remaining : how to know which firestore document payment was concerned by the one-time payment a customer make on the current checkout session?
Firestore does not update checkout session document with the payment id, or the payment document with the checkout session id.
I tried to update manually the webhook function on Google Cloud but I don't think that's a good idea (and I don't know why but the update was not considered).
I don't want to list all payment the customer made and displayed it : I want to have this specific payment and display a summary of this order.
Does someone has clues on this?
Yup, it appears that the function in the webhook handler does not add Checkout Session data with the associated Firestore payment document.
I'd recommend creating an issue on the GitHub repository with your feedback/request. Alternatively you can configure a 2nd webhook to update the Firestore documents as you need.

Stripe, how to retrieve payment history?

For my react app, I am using the Session object to handle purchases in Stripe, and I am using a Customer object if the user is logged in. I tried using Payment Intents, however it only gives me the total balance for each payment and not the actual items and their amounts that were purchased. I want to be able to retrieve the line_items a customer purchased in each payment (they're not Product objects if that helps).
Any help is appreciated!
You should retrieve the Session object, which does contain those.

How to retrieve a customer's payment history with Stripe?

For my react app, I am using the Session object to handle purchases in Stripe, and I am using a Customer object if the user is logged in. I'm having trouble figuring if I'm supposed to use the Payment Intent, Charge, or Balance Transaction object to retrieve a customer's payment history (provided the customer id).
Any advice is appreciated!
You would use the List all PaymentIntents API to get a customer's payment history:
https://stripe.com/docs/api/payment_intents/list
https://stripe.com/docs/api/payment_intents/list#list_payment_intents-customer
By default this will return the last 10 payments that the customer made. But, you can increase that number to 100:
https://stripe.com/docs/api/payment_intents/list#list_payment_intents-limit
If you want to list more than the last 100 payments you would need to use the auto-pagination feature provided by Stripe's libraries:
https://stripe.com/docs/api/pagination/auto
Depending on what information you need to display in your app you could also use the List Charges API. But that resource is being phased out in favor of PaymentIntents so I would look to use PaymentIntents first. The Balance Transactions API is mainly useful for displaying changes to a given Stripe account's balance rather than a given customer's payment history (i.e., tracking all payments, transfers, payouts and refunds on the account as a whole).

server side account check - is user registered (backand.com)

i currently stuck on building an account check like whatsapp.
When a user clicks on his smartphone on his/her contacts, it should display, which user has an existing account.
So in theory it should post all user contacts to server, server checks if there is an account with this email adresse and sends the "updated list" back to the client.
Sounds easy, but how do i do something like that :)
Getting the contacts is working, also posting contacts to server.
I had my backend on backand.com and building an app with Ionic/Angular.
This should be very simple.
The core functionality here is based on Backand built in 'users' object, it holds all users you've added to your app, a simple GET to this object will return all your users details including emails.
Now you can add a serverside js action that
gets the contacts details from the client-side app in the request body (as JSON)
does an $http call to the users object ro fetch exiting users.
loops the contacts and search for them in the users array

Resources