I now have the tracking event running properly, except: now when a user clicks the item in question, the event script fires, but also a dialogue of “Leave site? You’ll lose any unsaved changes.” pops up. Any idea why that might be occurring?
Interesting, and good find. I’ll test this out and see if I need to add it into my plug-in. I’ve read about something in the gtag docs where you have to manage timing issues when navigating away from the page.
Yes, I ran into exactly the same issue with a Stripe integration. Disabling / removing the handler for the beforeunload event resolved it for me. See if adding the following to the start of your script solves the problem:
Inside Google Ads you’re provided with tracking codes - snippets of Javascript code that you or your developer will place on your website or within your app