How to insert Microsoft Clarity Script

The Clarity tool from Microsoft provides session recording and heatmaps generation.

I want to insert their javascript code into my app.

Their instructions says to put the code below inside the <head> tag:

    (function(c,l,a,r,i,t,y){
        c[a]=c[a]||function(){(c[a].q=c[a].q||[]).push(arguments)};
        t=l.createElement(r);t.async=1;t.src="https://www.clarity.ms/tag/"+i;
        y=l.getElementsByTagName(r)[0];y.parentNode.insertBefore(t,y);
    })(window, document, "clarity", "script", "XXXXXXX");

I inserted it in App Settings -> Preloaded JS

But it's not working.

What do I have to do?

Thanks in advance.

1 Like

Hi @reslley,

I think this would require a feature request, unfortunately :disappointed:

We have some analytics integrations as outlined here, so we could explore whether it's possible to create a Microsoft Clarity integration, and we have an internal feature request for supporting embedding <script> elements into Retool apps in general.

1 Like

Do we have the feature now? I want to integrate clarity but I’m unable to since there is no space to paste the code

Hi @Vinyasa_Health! No update on this feature request yet :disappointed:

1 Like

is there a workaround? I want to check the analytics of the app and I'm on business plan.

I'm not aware of any workarounds.

You could have a query trigger on page load that saves some information about the app such as app name, date, etc to a database (assuming it isn't a public app, you could save the current_user information on page load to track page views by user)

it's a public app for external users.