Extend session across javaScript tracking and HTTP API

Hey All,
We got an ecommerce client that is using the JavaScript client on a headless site.
When a user converts in the payment gateway we send a custom http api request instead, the primary identifier we are using is in this case a email address (after consent).
Issue we are getting is that the session created on the website is not connected to the same user when converted, so attribution will not work correctly.

Any recommendations on how to tie these 2 up, in GA4 we would use session ID and number but not sure what Piwik PRO equivalent is?

Many thanks

Hey @FredrikWahlqvist, can you send the full URL with query parameters that you are using in order to send it through HTTP API?

Hey @kamilb , the query string is

const queryString = ? rec=${rec}& url=${url}& action_name=${action_name}& urlref=${urlref}& idgoal=${idgoal}& ec_items=${ec_items}& ec_id=${ec_id}& uid=${uid}& idsite=${idsite}& ec_sh=${ec_sh}& ec_dt=${ec_dt}& ec_tx=${ec_tx}& ec_st=${ec_st}& revenue=${revenue};

And it records the conversion correctly but as direct and it creates a new session when really it should be the same session

Hey @FredrikWahlqvist,

Can you please send the full request URL with values? I just want to see what values you are using.

Values from tracker debugger are

		"headers": [
				"application/json, text/plain, */*"
		"host": "XXXXXXXXXXX.piwik.pro",
		"ip": "<anonymized>",
		"method": "POST",
		"query_params": {
			"action_name": "XXXX",
			"ec_dt": "0",
			"ec_id": "1379-XXXX",
			"ec_items": "[{\"sku\":\"XXXX\",\"name\":\"XXXX\",\"category\":\"\",\"price\":\"XXX\",\"quantity\":1}]",
			"ec_sh": "4.95",
			"ec_st": "8.95",
			"ec_tx": "1.79",
			"idgoal": "0",
			"rec": "1",
			"revenue": "13.90",
			"uid": "XXXXXXX@gmail.com",
			"url": "https://checkout.stripe.com/",
			"urlref": "https://www.XXXXXXX.com/basket"
		"scheme": "https",
		"time": "2022-09-30T11:06:31.889248441Z",
		"user_id": "XXXXX@gmail.com"

Thanks for getting back as well.

Hey @FredrikWahlqvist,

I am just wondering if you are setting the User ID before the conversion?
Please note that it needs to be set before the conversion for the sessions to merge.
Also, can you please let me know if you have the consent turned on?

Hey, yes user id is set before conversion, not using Piwik Pro consent client is using quantcast and tag will only fire when got consent.