-
Notifications
You must be signed in to change notification settings - Fork 134
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
Amplitude callback isn't fired if a user enables adblock #142
Comments
Hi @tanin47, Could you explain why you would want this? Usually you should be firing and forgetting when you invoke logEvent and should not have any application logic depend on an event being logged. |
Well in my case, I need to log events before the visitor leaves a page so |
…are dropped (#342) * fixes #142 * fix error handling * revert commit * extend callback interface * fix callback call for deleted events * Added tests * single letter variable nit Co-authored-by: Donald Pipowitch <[email protected]>
I'm still observing the behavior described in this issue. Using the JS snippet currently on https://developers.amplitude.com/docs/javascript that attempts to load version 8.1.0. With uBlock Origin enabled on Chrome v89, Related, the console.log statement from the snippet ( |
Sure, after including the Amplitude snippet I define the following function: <script>
function outboundClick(e) {
amplitude.getInstance().logEvent("Outbound Link Clicked", null, function() {
window.location= e.target.href;
});
return false;
}
</script> And use it in my HTML like this: <a onclick="return outboundClick(event)" href="https://amplitude.com/">Check out Amplitude</a> With uBlock Origin disabled, it all works as expected: The event show up in amplitude and the browser navigates to https://amplitude.com/. My current workaround is to add a check to see if Amplitude was successfully loaded at the top of <script>
function outboundClickWithWorkaround(e) {
if (!e.amplitude.runQueuedFunctions) {
return; // Don't return false so links will behave like normal
}
amplitude.getInstance().logEvent("Outbound Link Clicked", null, function() {
window.location= e.target.href;
});
return false;
}
</script> This workaround is working fine for me, but isn't ideal since I'm having to peak inside the implementation of the Amplitude client. |
this issue is fixed by #413 , which was released with v8.4.0 The existing callback for logEvent has specific logic to only be called once (either right away if logEvent is misconfigured, or on logging success), so there is a second callback to logEvent that is called when logEvent fails, e.g when the user has an adblocker enabled |
One of our developers enables adblock and have found that the callback of
logEvent
isn't fired.I wonder if we can make the callback fires even the sending-data-to-amplitude action fails.
Thank you
The text was updated successfully, but these errors were encountered: