Hi, ran into another issue: weird things happen if I am both using the mixpanel gem and manually coding mixpanel events in my views. The problem occurs if I am tracking events in the "head" tag. The mixpanel gem will insert another mixpanel initialization script (i.e. setting up the "mpq" variable) before the end of the head tag, which stops my events from being tracked. So, the head code looks something like:
Init mixpanel manually
Track some events
Mixpanel gem inserts another mixpanel init script
The problem is fixed if I move my event tracking to the body tag, but it seems like there should be an option to stop the gem from insert the mixpanel init script.
If you are using the gem, which is the reason to track events outside the gem?
Yes, probably an option to no include mixpanel lib may work, pull requests with tests are welcome.
To track events from your models just call #track_event from there. A message queue or whatever async options you can use are desirable.
There are plenty of reasons to have your own MixPanel tracking code. We should strive to make a project that is direct-purpose and light-weight. Injecting code is good, but the Rails way has generally been to opt-in for page inject, e.g. <%= include_stylesheets :shadow, :media => 'all' %> from Jammit.
<%= include_stylesheets :shadow, :media => 'all' %>
Guys, I think is good to have opt-in js inclusion as long as it doesn't force existent users to change their current workflow.
Pull requests are welcome!