Hello, we have an issue with identification and tr...
# support
f
Hello, we have an issue with identification and tracking to Posthog (cloud integration). We’re using the JS and the Ruby SDKs. We track pageviews and custom events. • when tracking an anonymous user, we submit only a (self-generated) anonymous ID, and no distinct ID. ◦ Rudderstack submits our anonymous ID as distinct ID to Posthog, plus the same string again as anonymous ID • when this user later logs in, we track the same anonymous ID together with a distinct ID. We also indentify the user. ◦ Rudderstack submits the distinct ID as distinct ID to Posthog, plus the anonymous ID. The problem is that the users are not matched on Posthog. If the same anonymous ID is submitted with 2 different distinct IDs, they are not joined together. Question is: why does Rudderstack submit a distinct ID to Posthog if we only provide an anonymous ID? I think it should just omit the distinct one, so that the anonymous ID can still be matched when the user logs in?
s
Hey There! 👋 Your message has been received by the RudderStack team. Our standard customer support hours are 9-6 PM EST, but we will forward this request to your Technical Account Manager, and they will get back to you shortly. Please use the thread for any additional comments.
f
note: we will now try to use
alias
as a workaround to join them together, but it seems not correct to create a user with anonymous ID as distinct ID in the first place.
Posthog errors
h
"same anonymous ID is submitted with 2 different distinct IDs" why would this happen?
f
“same anonymous ID is submitted with 2 different distinct IDs” why would this happen?
because Rudderstack first submits our anonymous ID as distinct ID, and then our distinct ID as distinct ID, for the same user
h
Looking at the transform it should only ever set distinct when there is a user_id in the event - are you using a distinct_id on your side too rather than sticking with anon_id/user_id
f
let me check
• In Ruby it tracks only the
anonymousId
, • in JS it tracks `anonymousId`and an empty
"userId": ""
for some reason
This goes to posthog
Copy code
"$anon_distinct_id": "7555cf5c-42f4-440d-a126-ff4251c70f78"
            },
            "distinct_id": "7555cf5c-42f4-440d-a126-ff4251c70f78"
        },
        "JSON_ARRAY": {}
    },
    "type": "REST",
    "files": {},
    "method": "POST",
    "params": {},
    "userId": "",
I cannot see anywhere where it sets distinct from anon
that looks like a bug to me
👀 1
suggest you raise an issue (I am not from rudder)
f
ok, thanks alot!
maybe one more question, do you know if the userID is required in JS, or why would we submit an empty one?, should it be omited?
h
it comes through as empty string if not set via an identity call
image.png
gratitude thank you 1
q
Thank you @hundreds-lifeguard-65770 @flaky-ability-44647 I have forwarded this to Engg team. They will look into it.
👍 1
gratitude thank you 1
f
Hey @hundreds-lifeguard-65770, @flaky-ability-44647 I tried to replicate this issue by the following calls: 1.
Copy code
{
  "anonymousId": "anon-id-new17957",
  "context": {
    "traits": {
      "trait1": "new-val",
      "name": "test User 1 updated"
    },
    "ip": "14.5.67.21",
    "library": {
      "name": "http"
    }
  }
}
2.
Copy code
{
  "userId": "user17957",
  "anonymousId": "anon-id-new17957",
  "context": {
    "traits": {
      "trait1": "new-val",
      "name": "test User 1"
    },
    "ip": "14.5.67.21",
    "library": {
      "name": "http"
    }
  }
}
And these results in creating one user only with two ids. Let me know if am I missing anything to replicate this issue.
f
thanks! yes, if submitted like this, it will work. The problem is this: • when tracking an anonymous user, we submit only a (self-generated) anonymous ID to Rudderstack, and no distinct ID. ◦ but: Rudderstack submits our anonymous ID as distinct ID to Posthog, plus the same string again as anonymous ID Let me hand over to my teammate, who is currently working on this…
Copy code
IN to Rudderstack:

{
    "anonymousId": "58bad4b5-7033-412f-bb4d-404bcceef7ec",
    "context": {
        "library": {
            "name": "rudder-sdk-ruby-sync",
            "version": "1.0.7"
        },
        "page": {
            "path": "/",
            "referrer": "https://www.ofri.it/jobs",
            "url": "https://www.ofri.it/"
        },
        "traits": {},
        "userAgent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36"
    },
    "event": "Handwerker gesucht? Kostenlos Offerten einholen",
    "integrations": {
        "All": true
    },
    "messageId": "947823b8-0a9b-42cb-96fc-ea838d2d97d5",
    "name": "Handwerker gesucht? Kostenlos Offerten einholen",
    "properties": {
        "name": "Handwerker gesucht? Kostenlos Offerten einholen"
    },
    "rudderId": "14654a64-804f-47b5-a6bd-37a3b0b7011f",
    "sentAt": "2023-01-17T10:18:54.586Z",
    "timestamp": "2023-01-17T10:18:54.586Z",
    "type": "page"
}

OUT to Posthog:

{
    "body": {
        "XML": {},
        "FORM": {},
        "JSON": {
            "name": "Handwerker gesucht? Kostenlos Offerten einholen",
            "type": "page",
            "event": "$pageview",
            "api_key": "xxx",
            "messageId": "947823b8-0a9b-42cb-96fc-ea838d2d97d5",
            "timestamp": "2023-01-17T10:18:55.388Z",
            "properties": {
                "$ip": "80.240.16.190",
                "$lib": "rudder-sdk-ruby-sync",
                "$set": {},
                "name": "Handwerker gesucht? Kostenlos Offerten einholen",
                "$host": "www.ofri.it",
                "$time": "2023-01-17T10:18:55.388Z",
                "$pathname": "/",
                "$timestamp": "2023-01-17T10:18:55.388Z",
                "$useragent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/108.0.0.0 Safari/537.36",
                "distinct_id": "58bad4b5-7033-412f-bb4d-404bcceef7ec",
                "$current_url": "https://www.ofri.it/",
                "$lib_version": "1.0.7",
                "$anon_distinct_id": "58bad4b5-7033-412f-bb4d-404bcceef7ec"
            },
            "distinct_id": "58bad4b5-7033-412f-bb4d-404bcceef7ec"
        },
        "JSON_ARRAY": {}
    },
    "type": "REST",
    "files": {},
    "method": "POST",
    "params": {},
    "userId": "",
    "headers": {
        "Content-Type": "application/json"
    },
    "version": "1",
    "endpoint": "https://eu.posthog.com/batch"
}
Rudderstack sends a
distinct_id
to Posthog, even though we did not track one. I think this is not correct.
f
Are you asking not to send distinct_id for anonymous users?
h
Why would you since their distinct_id is rudders user_id
f
Are you asking not to send distinct_id for anonymous users?
yes, exactly
either it’s anonymous or distinct, but not both?
f
Sorry, I am not getting how is it effecting user tracking? We can stop putting anonymousId as distinct_id if it is causing any issue.
f
OK, we were just now able to fix our issue by removing an identify call with the anonymous ID, which we had too early. It turns out Posthog matches the users correctly, as long as they are not explicitly identified (just tracked). So the above behaviour did not cause the issue we had with tracking. Sorry about that. Having said that, it still seems wrong to me to track distinct and anonymous IDs in the way described above. But a change would require testing I guess. Thanks so much for the super quick support!
🙌 1