How to use mixpanel with twitter bootstrap popup menu?
My code is as follows:
<div class="navbar">
<div class="navbar-inner">
<div class="container">
<ul class="nav pull-right">
<% if user_signed_in? %>
<li class="dropdown" id="menu7">
<a class="dropdown-toggle" id="username" data-toggle="dropdown" href="#">
<%= current_user.full_name %>
<b class="caret"></b>
</a>
<ul class="dropdown-menu">
<li><%= link_to('Edit my account', edit_user_registration_path,
:id => 'edit_account') %></li>
<li><%= link_to('Logout', destroy_user_session_path, :method => 'delete',
:id => 'logout_link') %></li>
</ul>
</li>
<% else %>
<li><%= link_to('Login', new_user_session_path, :id => 'login_link') %></li>
<li><%= link_to('Sign up', new_user_registration_path, :id => 'signup_link') %></li>
<% end %>
</ul>
</div>
</div>
And my javascript events are as follows:
mixpanel.track_links('#username', 'Username clicked')
mixpanel.track_links('#edit_account', 'Edit account link clicked')
mixpanel.track_links('#logout_link', 'Logout link clicked')
I don’t know why (I really look weird!) Only the "Username clicked" event works. Has anyone experienced something like this?
+5
1 answer
One possibility is that you need to include the link tag in your selector:
mixpanel.track_links('#username a', 'Username clicked')
mixpanel.track_links('#edit_account a', 'Edit account link clicked')
mixpanel.track_links('#logout_link a', 'Logout link clicked')
How to do this in a Mixpanel Document .
Another option is that you may be mistaken. Instead of tracking clicks on links, perhaps you want to use the ruby API and put your trackers in the controller, as shown in this part of the document .
, - Users:
def edit
track_event "edits account"
end
:
def destroy
track event "logs out"
end
0