New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Callback after tracking goal #13679
Comments
it's not possible yet but added a pull request for this in #13680 . Will be available with Matomo 3.8 (not 3.7). Just out of curiosity, do you mind more explaining your use case what you do in the callback? |
On our website we have a lot of javascript functionality. We want to track the usage of some features. One of the simpler features is a whatsapp contact button, when the button is pressed and the javascript magic has happened we wish to send the people to their destination so the whatsapp window will open. Unfortunately if you send someone directly to a third party site a lot of browsers will drop pending requests and those may not be adequately tracked. By having a callback at the end you can queue up several requests that should happen before sending the user on it's way. In our app for example we have analytics, adwords and want to chain motomo too for experimenting with the features of motomo. How our chain currently works:
Right now, the motomo push get's dropped a lot because the google analytics callbacks are handled much faster than the piwik response on our server, which causes the browser to move to whatsapp before motomo is ready to accep/log. By having a callback features, one can chain motomo in any other request and make sure everything is logged properly. |
Cheers, that helped 👍 FYI: In Matomo 3.8 we will also have an option to use sendBeacon when it is available in the browser see #13451 and eventually it'll become the default: #13681 You may want to consider enabling this once it is available and then you wouldn't need to wait for the requests to finish and end up having bit faster UI there. It's supported in most browsers: https://caniuse.com/#search=sendbeacon Unfortunately, sendBeacon does not let us know when the request is finished so you wouldn't be able to use the callback for other browsers unless you really checked whether sendBeacon is being used or not. |
From MDN
You can use this in a callback feature. call the callback when it returns true, throw an error if it fails, even better, use a promise for easy handling all cases. |
True we could just assume the request worked when sendBeacon works. I just see I've implemented that actually already in #13451 :) |
https://developer.matomo.org/guides/tracking-javascript-guide#manually-trigger-goal-conversions
Is it possible to have a callback function? if so how?
I found https://forum.matomo.org/t/callback-after-tracking-a-goal-with-javascript/3190, which leads to #10337 which leads to #10467 which leads to 04d0c74
but I have no clue after all this what i'm supposed to insert into the _paq.push(['trackGoal', 1]) to get a callback event working after the request has been sent to matomo and received back.
Is this a feature that is present but undocumented? If so, how can I use it in goal tracking?
The text was updated successfully, but these errors were encountered: