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

  • SEARCH
  • Home
  • 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 8057907
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T09:11:03+00:00 2026-06-05T09:11:03+00:00

I use Facebook JSSDK (i.e client-side) to verify who the current user to my

  • 0

I use Facebook JSSDK (i.e client-side) to verify who the current user to my web-app is.

Code looks something like this:

    ... inited google analytics ...

       ...
       //events *before* authentication
       _gaq.push(['_trackEvent', 'TEST', 'EVENT BEFORE AUTH', 1]);   

       ... 
       //events *after* attempt at client-side authentication
       // callback might return after, say, 7 seconds
        authenticateUser(function(userInfo) {
             // setting visitor-level custom var
            _gaq.push(['_setCustomVar', 1, 'AUTHED-USER', userInfo, 1]);
            _gaq.push(['_trackEvent', 'TEST', 'EVENT AFTER AUTH', 1]);   
        });

(If you try simulating this, please make sure you run “setCustomVar” quite a while after the first event fires – as you want to give GA “enough time” to already send the first event)

This creates the following “Issues” with tracking events under custom variables:

  1. The response from Facebook, with the user’s info might return after other events were already sent to Google Analytics – A visitor-level custom variable seems to “solve this” because it seems like even events that were tracked previously in this session (before the custom var was set) are listed “under” the custom var value (that was set after them).

  2. A different user might use the same browser to use the app. The behaviour of “over-writing” the visitor-level custom variable is problematic – it seems that ALL pre-auth events that were issued from this browser are listed/grouped under the LATEST custom-var value. I tried issuing a _deleteCustomVar call before overwriting – but this did not solve the issue.

To differently “solve” the first issue – I thought of not using a visitor-level custom var (but rather a page/session one) – but this would mean all the pre-auth events would not be listed under the custom var – To solve this I thought to somehow defer all the event-tracking to after the auth has been done – but this seems.. umm.. weird.

Another solution would be to use my own “visitor-cookie”. But GA already does that so I am reluctant to re-invent the wheel.. (and also after a user-switch, the visitor’s cookie will be “lying” for pre-auth events)

Any suggestions to how to tackle this scenario?

  • 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-06-05T09:11:05+00:00Added an answer on June 5, 2026 at 9:11 am

    Maybe a little explanation of each customVar scope will help you.

    Visitor Level CV

    The visitor level CV will apply to all visits from the moment you set the CV on. If you ever change the CV during a single visit that visit will be listed in GA under the old value, but future visits will have the updated CV.

    Session Level CV

    The session level CV is only valid in the current session. In a future session it’s empty. If you ever change a Session level CV during a visit the value reported in GA is the last one.

    https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingCustomVariables#usage

    The last session-level variable called in a session is the one used
    for that session. Example: If login=false for slot #1 at the
    beginning of the session and login=true for slot #1 later on, the
    session is set to true for login.

    Over-rides any previously-set page-level variable called in the same
    session. Example: If slot #1 is first used for category=sports and
    then for login=true for a session, category=sports will not be
    recorded for that session.

    Page Level CV

    You have to be careful with this one in your case. When you use a Page Level CV never look at visits as a metrics, always use pageviews (or totalEvens if you fire an event immediately after setting the CV).

    Which one to use?

    Now answering your question. I would first ask myself if there’s any reason to believe that multiple users would be using the same browser. I’ve seen systems that were made for kiosk like computers, and in that case it’s a totally valid point. But other than the ammount of users you might have using the same browser might be irrelevant for your metrics.

    Even in the case of using the same browser If you use the session level CV it will always be blank until the user sets it, and if he changes it during a visit you will get the lates one which is probably what you want. The only down side of using a session level CV is that if the user never signs-in you will have no CV for that visit.

    So if you have any reason to believe that your audience has a good chance of sharing the same browser with multiple users than I’d go with a session level CV. Otherwise I’d keep a user level CV since the value has a low chance of changing and because that way you’d have a CV even if the user decides not to login during a specific visit.

    PS

    I don’t know if the events in your code are just examples but they are wrong. The first 3 arguments in an event are strings, and it seems you’re passing 2 strings and an integer.

    You definitivelly need an event or pageview after you set a CV, setting a CV doesn’t send a hit to GA, so its strictly necessary that you send a hit. If you’re sending an event just for the sake of having the CV registered, you better send an event like this:

    _gaq.push(['_trackEvent', 'CV', 'set', '', 0, true]); 
    

    this will fire a non-interactive event, and it won’t impact metrics like bounce-rate.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can I use Facebook PHP SDK to deauthorize my app for a particular user,
I'm concerned that when I use Facebook's feed dialog I'm making my App Id
I have to develop web2py app and have to use Facebook sdk in that.
I'm trying to use the Facebook iOS feed dialog call to allow my app's
I am trying to use some Facebook code in one of my pages. The
I'm trying to use Facebook SDK in my Android app. Here's the snippet: Facebook
I want to use Facebook ID to welcome all facebook user that enter my
I'm trying to use SDK Facebook to detect the click on the button like
I have used the following code to use FB Like on my website...but clicking
I'm writing a Facebook iframe/canvas app and would like to give users the ability

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.