Added callbacks for analytics integration #1
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
I actually haven't figured out how to test whether or not the referrer gets through until data starts showing up in production. I can see the events firing with a debugger; I'll let you know after a couple of days in production. I don't know why it wouldn't include referrer, because the original cause should be fixed.
The problem is: when you call ga() events in the context of the iframe, it treats the enclosing page as the referrer. If you make ga() calls there, thats what it will get.
My solution was: have the celery code in the iframe hook into callbacks in the parent window. Basically at each step, Celery checks to see if a callback e.g. named "onCeleryOrderPlaced" exists. If it does, it fires the callback.
So in the parent window, the onCeleryOrderPlaced function makes the ga() call. It's using the ga() function that was created in the context of the parent window.
Celery users will be able to write whatever callback handlers they want. You could provide a set of vanilla ga callbacks, or they could write their own for any analytics or tracking system.