javascriptreactjshotjar

Implement Hotjar's feedback component in a React app?


As near as I can the hotjar initialization is firing. I see the library getting requested in devtools. However I don't see any subsequent requests to hotjar nor does the feedback component load.

I'm trying to wrap the whole root component with Hotjar i.e.:

  let hotjarInit = false;
  useEffect(() => {
    if (!hotjarInit) {
      const siteId = process.env.REACT_APP_HOTJAR_ID;
      const hotjarVersion = 6;

      if (siteId) {
        console.debug('Initializing Hotjar');
        Hotjar.init(Number(siteId), hotjarVersion);
        hotjarInit = true;
      } else {
        console.error('Could not initialize Hotjar, no siteId found');
      }
    }
  }, []);

Is there a better way to go about this?


Solution

  • Resolved. It just took some time to propagate the initial results, and the URL needed more permissive mathcing.