title: How to differentiate Login from Sign up when using PassportJS for Facebook
body: <p>I am trying to set up goals on Google Analytics to track Sign Ups, so I set up a 'thank you ' page as my url goal. It works well when my users sign up with their email address but not when they use facebook to sign up/login. When they login, they are redirected to the thank you page as there is only one url callback when setting up Facebook using Passport JS and Node. </p>
  
  <p>Here is my code:</p>
  
  <pre><code>passport.serializeUser(function(user, done) {
    done(null, user);
  });
  
  passport.deserializeUser(function(id, done) {
    UserActivity.findOne(id,'uid ref', function (err, user) {
      done(err, user);
    });
  });
  
  
  passport.use(new FacebookStrategy({
      clientID: 'XXXXXXXXXXXX',
      clientSecret: 'XXXXXXXXXXXXXXXX',
      callbackURL: "https://www.xxxxxxx.com/auth/facebook/callback"
    },
    function(accessToken, refreshToken, profile, done) {
      //console.log(profile);
      User.findOne({ uid: profile.id }, function(err, uInfo) {
        if(err) console.log('Error: '+err);
        else{
          //User exists: we are done
          if(uInfo){
            done(err, uInfo);
          }
          else{
              //User doesn't exist: we create a new one
              var newUser = new User ({
                uid: profile.id,
                email:profile.emails[0].value,
                ref: 'Facebook'
              });
              // Saving it to the database.  
              newUser.save(function (err,uInfo) {
                if (err) console.log ('Error on save!');
                done(err, uInfo);
              });
          }
        }
      })
    }
  ));
  
  app.get('/auth/facebook', passport.authenticate('facebook',{ scope: 'email' }));
  app.get('/auth/facebook/callback', 
    passport.authenticate('facebook', { successRedirect: '/thankyou',
                                        failureRedirect: '/login' }));
  </code></pre>
  
  <p>If the user exists, I would like to redirect to their dashboard ('/dashboard) and if they are new users, I need to redirect them to /thankyou.
  Any idea how to achieve this?</p>
  
  <p>Thanks a lot!</p>