MixPanel Javascript on Rails app sends to route ‘/undefined’

I’m trying to use MixPanel’s javascript for web to track our new user signup flow.

Simply put, when a user clicks the ‘signup’ button–or anything that the MixPanel JS is referring to–the app is then directed to ‘/undefined’. The action is successfully tracked in MixPanel, but of course, the app is broken and the user isn’t created because of this.

This is an example of what my Mix Panel code looks like (in a script tag on the bottom of the embedded ruby html file):

  // MixPanel - User Signup Button
  mixpanel.track_links("input .signup-btn", "Create User Account", {
    "referrer": document.referrer
  });

I don’t get what ‘document.referrer’ actually does, I just followed MixPanel’s docs.

This function is on the view and the form is in a render partial on the view. Though I can’t imagine that being an issue because the JS comes at the bottom of the page.

I’m not using MixPanel’s gem. My rails app just consumes our API. There are no models or users so the gem is overkill in this situation. I just need to simply track each step of the signup process solely from a front-end perspective.