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

Added callbacks for analytics integration #1

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

sdebaun
Copy link

@sdebaun sdebaun commented Mar 26, 2014

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.

@ptshih
Copy link
Contributor

ptshih commented Mar 26, 2014

Thanks for looking into this. I like the approach you took, I tried to do something similar by attempting to fire tracking beacons on behalf of the parent window (you can see some remnants of that in o.js but it didn't seem to work).

I'll do some testing on our side as well with your implementation. Looking forward to your findings!

@sdebaun
Copy link
Author

sdebaun commented Mar 27, 2014

My pleasure! It was fun. Let me know if you have any questions or find any problems. I'm rolling it to production on my site today.

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

Successfully merging this pull request may close these issues.

2 participants