No option to stop inclusion of javascript initialization #22

Closed
smidwap opened this Issue Nov 28, 2011 · 5 comments

Projects

None yet

3 participants

@smidwap
smidwap commented Nov 28, 2011

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.

Owner

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.

smidwap commented Nov 29, 2011

I'm not so sure there is a great reason. I am learning how to integrate
Rails & mixpanel for the first time, and it's an interesting undertaking.
For example, I've found several cases where I need to track events in
Models instead of Controllers. The mixpanel gem isn't really set up to do
that, but I'm figuring it out.

On Mon, Nov 28, 2011 at 1:03 PM, Alvaro Gil <
reply@reply.github.com

wrote:

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.


Reply to this email directly or view it on GitHub:
#22 (comment)

Matt De Leon / ASSOCIATE PARTNER
219.309.0213

CELL

|
@naivethought

DeveloperTown TURN YOUR IDEA INTO A BUSINESS
developertown.com | 855.338.8696 | @developertown
*

Owner

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

hayesgm commented Jan 30, 2012

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.

Owner

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!

@zevarito zevarito closed this Aug 9, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment