I have a Newsletter2go subscription form on my site. I need to track the subscription with Google Analytics. Alas, Newsletter2Go only offers the display of a text, but no page redirect after the form was successfully submitted.
What I think should be done on my side is that I somehow need to catch the load event after the AJAX event was issued from the Newsletter2go script (which I cannot change).
My last resort would be to use MutationObserver to watch for Changes in the DOM (form disappears and Thank You text shows), but I suppose there should be a better way.
document.addEventListener('load', /* ... */) and window.addEventListener('load', /* ... */) didn't do anything
There is this help topic 'How can I embed and customize the subscription form?'.
I only have the German version of the support text: https://newsletter2go-help-de.sendinblue.com/automation/formulare/wie-kann-ich-das-anmeldeformular-verwenden-einbetten-und-anpassen.html
In the chapter Customize form > 2 For coders there is the solution described:
You can add callbacks to the call for
subscribe:createForm. First issuccessCallback