clarity icon indicating copy to clipboard operation
clarity copied to clipboard

Send custom ID's to clarity

Open OmriBenShoham opened this issue 1 year ago • 4 comments

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.

OmriBenShoham avatar Jan 03 '24 15:01 OmriBenShoham

👍

GalDayan avatar Jan 04 '24 07:01 GalDayan

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

Dbwani avatar Jan 06 '24 11:01 Dbwani

Any help here?

OmriBenShoham avatar Jan 09 '24 16:01 OmriBenShoham

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

cyfyifanchen avatar Feb 18 '24 05:02 cyfyifanchen

Duplicate of #400.

AbdelrhmanMagdy avatar Mar 20 '24 14:03 AbdelrhmanMagdy