Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6855775
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T01:48:02+00:00 2026-05-27T01:48:02+00:00

I’m looking at the Kissmetrics (analytics app) JS API docs, and they have an

  • 0

I’m looking at the Kissmetrics (analytics app) JS API docs, and they have an “identify” method that lets you tell Kissmetrics about a user. Here’s what their docs say:

We recommend you call identify in two scenarios:

When a user successfully signs up
When a user successfully logs in, either through cookies or through a login page

What would be the best way to achieve that? How can I detect when a user has just signed up or signed in?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-27T01:48:03+00:00Added an answer on May 27, 2026 at 1:48 am

    Lets divide the problem in two: register and log in.

    You can detect when a new user has registered in you app just adding a after_create hook in you User model. Something like

    class User < ActiveRecord::Base
      after_create :register_hook
    
      def register_hook
        # your code here
      end
    end
    

    Detecting when the user logs in is a little bit dirtier. Devise modify the user.current_sign_in_at attribute of the user when he/she logs in, so you could add a before_save hook in the user model and check if the current_sign_in_at attribute has changed. It should be something like:

    class User < ActiveRecord::Base
      before_save :login_hook, :if => current_sign_in_at_changed?
    
      def login_hook
        # your code here
      end
    end
    

    Once you have the right callbacks for detecting sign in/sign up, you can just create a cookie with the info and read it from the javascript or write a helper method for the User model and write something like this in your layout:

    <% if current_user.just_signed_in %>
      <script type="text/javascript">
        // Your sign in stats code here
      </script>
    <% end %>
    
    <% if current_user.just_signed_up %>
      <script type="text/javascript">
        // Your sign up stats code here
      </script>
    <% end %>
    

    Following this way, the complete model would be:

    class User < ActiveRecord::Base
      after_create :register_hook
      before_save :login_hook, :if => current_sign_in_at_changed?
    
      attr_accessor :just_singed_up, :just_signed_in
    
      def register_hook
        @just_signed_up = true
      end
    
      def login_hook
        @just_signed_in = true
      end
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I am using Paperclip to handle profile photo uploads in my app. They upload
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
this is what i have right now Drawing an RSS feed into the php,
I've got a string that has curly quotes in it. I'd like to replace

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.