Geek asks and answers

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
ruby-on-rails twitter bootstrap mixpanel
Diego gomes Aug 14 '12 at 2:50
source share
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
Dreyfuzz 26 . '15 18:27

More articles:

  • отправить письмо со ссылкой - php
  • Does the conversion from DbSet to IEnumerable query? - entity-framework
  • Поиск минимального уникального числа в массиве - algorithm
  • number of working days in python - python
  • Completely free singleton Objective-C - design
  • Scala pattern matching in parallel program - scala
  • Rails migration: is it possible to use 'nil' as the default value for a boolean field? - ruby-on-rails
  • PHP static class or namespace - php
  • IOS brush hardness like Photoshop - ios
  • PHP namespaces and classes with static functions - php

All Articles

Geek-Ask | 2020