Skip to content
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

Compare data before dispatching #199

Open
Nuhasami opened this issue Mar 9, 2022 · 1 comment
Open

Compare data before dispatching #199

Nuhasami opened this issue Mar 9, 2022 · 1 comment
Labels

Comments

@Nuhasami
Copy link

Nuhasami commented Mar 9, 2022

First of all, thank you for this really neat work!

Secondly, I simply want to make sure I don't send duplicates. I was thinking maybe I can check prevData and currentData before dispatching in useTracking. Is there a way to do that? I hope my question is clear, apologies if it's not. 😸

@tizmagik
Copy link
Collaborator

Thanks for the kind words!

Hmm I don't think we have anything out of the box to do this but I think you should be able to push to some persistent array during your dispatch() call and then compare with the previously dispatched event. If it is a dupe you can just return early and not push to your dataLayer.

Happy to look at an example if you have a more concrete use case you'd like to discuss.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants