I'm woking on a basic implementation of RudderStac...
# support
c
I'm woking on a basic implementation of RudderStack using the JS SDK on the web to track page views, with the first destination being ActiveCampaign, and I'm having problems understanding the
Identify
method. I've got anonymous tracking working (i.e. script installed, page views being collected in RudderStack) however I'm at a loss for how to implement the Identify method. I already have JavaScript on my site that provides information when someone is logged in. I'm hoping to "bind" RudderStack
Identify
to this somehow. Can you please help?
Here is the javascript already on my page when someone is logged in:
Copy code
<script type="text/javascript">
    window.circleUser = {
      firstName: 'Casey',
      lastName: 'Schorr',
      name: 'Casey Schorr',
      email: 'email@gmail.com',
      isAdmin: 'true',
      isModerator: 'false',
      publicUid:  'a0c1a6d0',
      location: '',
      websiteUrl: '',
      linkedinUrl: '',
      twitterUrl: '',
      facebookUrl: '',
      signedIn: true
    }
</script>
Here is the javascript already on my page when someone is logged out (i.e. anonymous)
Copy code
<script type="text/javascript">
    window.circleUser = {
      signedIn: false
    };
</script>
In the documentation (https://www.rudderstack.com/docs/sources/event-streams/sdks/rudderstack-javascript-sdk/supported-api/#identifying-new-users) it says to Call
identify
with a new
userId
I don't know what I should pass for userId. • Do I have to provide a userId? • ActiveCampaign uses email as the main ID. Do I set userId to the email address? Or is that best sent as a trait? The example identify call in the ActiveCampaign documentation is confusing to me as it has
userId
in the code (i.e. no actual userId) https://www.rudderstack.com/docs/destinations/streaming-destinations/activecampaign/#identify • I have a
publicUid
available to me from the javascript (see code example above) I could use, but that's really just for this website and doesn't necessarily represent our "key" for each user. We also have auth0 for example, which has different ID for the user. apologies in advance, I am more on the business/marketing side hacking this together vs a sophisticated developer
h
you would typically not use an email address as a user_id as folk can change their email
you would normally have a uuid to go alongside the email which you would use to identify after they have logged in
I'd say the auth0 id is fair game to use as long as its stickey to that user
c
got it. if i don't pass a
userId
what happens? Here's a test call I made just now into our account not passing anything for userId (but I am including the
email
)
Copy code
{
  "anonymousId": "bc5774bf-6656-4d8b-a99a-841f707ac5ee",
  "channel": "web",
  "context": {
    "app": {
      "name": "RudderLabs JavaScript SDK",
      "namespace": "com.rudderlabs.javascript",
      "version": "2.37.0"
    },
    "campaign": {},
    "library": {
      "name": "RudderLabs JavaScript SDK",
      "version": "2.37.0"
    },
    "locale": "en-US",
    "os": {
      "name": "",
      "version": ""
    },
    "page": {
      "initial_referrer": "https://tagassistant.google.com/",
      "initial_referring_domain": "tagassistant.google.com",
      "path": "/home",
      "referrer": "https://tagassistant.google.com/",
      "referring_domain": "tagassistant.google.com",
      "search": "?gtm_debug=1689107520856",
      "tab_url": "https://www.hedgian.com/home?gtm_debug=1689107520856",
      "title": "Home | Hedgian",
      "url": "https://www.hedgian.com/home?gtm_debug=1689107520856"
    },
    "screen": {
      "density": 2,
      "height": 1440,
      "innerHeight": 1358,
      "innerWidth": 1713,
      "width": 2560
    },
    "sessionId": 1689106503772,
    "traits": {
      "email": "caseyschorr@gmail.com"
    },
    "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/113.0.0.0 Safari/537.36"
  },
  "integrations": {
    "All": true
  },
  "messageId": "4e16f113-5f5c-4a45-917d-b202bac4b752",
  "originalTimestamp": "2023-07-11T20:32:03.324Z",
  "rudderId": "2d8aa327-b346-406e-8255-a3a5ebe2105d",
  "sentAt": "2023-07-11T20:32:03.324Z",
  "type": "identify",
  "userId": ""
}
h
the impacts will vary - it depends on your downstream integrations
c
What do people do when there are two sign-up flows so to speak... 1. someone can fill out an online form, providing just their email address (for example to sbuscribe to a newsletter) 2. someone can sign up properly (auth0) In #2 there's probably a 'good' uuid. But what about #1, and what abou people that start with #1 but then progress to #2 ?
h
normally you identify and can then stitch the users anonymous vists with their logged in journeys
c
^ yes, i am trying to capture their anonymous visit history / data, as soon as they log in and pull all that in so to speak.
the marketing automation software i've used in prior jobs... it kindof handles the form submit tie to a user / email and whatnot 'automatically' didn't have to think this deeply about it.
h
so you could just use what you have available, if they go from 1 to 2 you can identify again with updated info and join back twice
but again depends - if your using a data warehouse that is easy - other tools may not be so easy
c
i undestand 'identify again' ... but how do you 'join back'? if I pass the same email when I identify again, does it automatically know to join them?
h
depends what 'it' is
c
oh, is that logic handled at the destinations?
h
each destination system will have it's own rules on how to stitch between identity, rudder tries it's best to uphold to their api
c
thank you.
PS - this segment documentation kinda answers my question on when to use AnonymousID vs UserID https://segment.com/docs/connections/spec/identify/#anonymous-id
Also this is super helpful. RudderStack should copy for your own docs! https://segment.com/docs/connections/spec/best-practices-identify/
@hundreds-lifeguard-65770 if I submit an identify call from auth0 that has a unique
userId
using a webhook, will that update the Javascript SDK
userid
?
I can send a uuid via auth0 using webhook. but all of the other tracking is done with javascript sdk. trying to ensure if uuid is set via webhook, that the anonymous website visit(s) before the uuid is set (i.e. before signup) will merge properly.
h
no you would need to receive that id on the client then use
✅ 1
c