Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP


No option to stop inclusion of javascript initialization #22

smidwap opened this Issue · 5 comments

3 participants

Matt De Leon Alvaro Gil Geoff Hayes
Matt De Leon

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.

Alvaro Gil

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.

Matt De Leon
Alvaro Gil

To track events from your models just call #track_event from there. A message queue or whatever async options you can use are desirable.

Geoff Hayes

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.

Alvaro Gil

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!

Alvaro Gil zevarito closed this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.