microsoft / clarity

A behavioral analytics library that uses dom mutations and user interactions to generate aggregated insights.
https://clarity.microsoft.com
MIT License
2.16k stars 214 forks source link

Send custom ID's to clarity #518

Closed OmriBenShoham closed 8 months ago

OmriBenShoham commented 10 months ago

As part of our usage in Microsoft Clarity, we want to send our own IDs, for example: user_id, user_email. We couldn't find a way to do so, this is our code:

import { clarity } from "clarity-js";

  const { user, isLoading } = useUser();

  useEffect(() => {
    if (!isLoading) {
      clarity.consent();

      if (user?.sub) {
        clarity.identify(user.sub, "", "", user.sub);
        clarity.set("user_id", user.sub);
      }

      if (user?.email) {
        clarity.set("user_email", user.email);
      }

      clarity.start({
        projectId: process.env.NEXT_PUBLIC_MICROSOFT_CLARITY,
        upload: "https://m.clarity.ms/collect",
        track: true,
        content: true,
      });
    }
    return () => {
      clarity.stop();
    };
  }, [user, isLoading]);

The variables I was trying to send from here are user.sub(our custom user id) and user.email which is our user email, Please assist here what i'm missing in order to send those variables.

GalDayan commented 10 months ago

đź‘Ť

Dbwani commented 10 months ago

I have been using Microsoft Clarity wordpress plugin from a long time. Few days ago, I installed the plugin on my new wordpress site namely Toply10. While google analytics is working finely on my site, but Microsoft Clarity plugin isn't showing up any realtime data especially in “Heatmap” section. I have already cleared all cache of my website many times, but still it shows some error like “Curl Error 7”. Is there anyone who can help me to sort out this problem?

Please note that I am using “Litespeed Cache“ plugin on my site. I feel like there arises some conflict between the two plugins. I have already reported to the microsoft clarity team.

Here is my website url: my website - Toply10

OmriBenShoham commented 10 months ago

Any help here?

cyfyifanchen commented 9 months ago

@OmriBenShoham take a look at https://github.com/microsoft/clarity/issues/400.

AbdelrhmanMagdy commented 8 months ago

Duplicate of #400.