Script tag for analytics
Unanswered
Sun bear posted this in #help-forum
Sun bearOP
guys for analytics and the script tags im using the Script tag from nextjs i notice events are fired but the apps dont detect that the tracking is setup, has it have to do with the stragey like afterInteractive or ?
appreaciate help tahnks.
appreaciate help tahnks.
21 Replies
Can you share your script?
Carpenter wasp
but the apps dont detect that the tracking is setup
You'll have to be more specific - how the script is injected and how you observe that the "apps dont detect that the tracking is setup" - which code chekcs it and how.
Most common case would be that you initialize something like GTM or Posthog with raw scipt tag, but then use e.g. react library to interact with it. If Iguess correctly, the correct solution would be to use native library only.
Sun bearOP
yeah let me share
so im using the nextjs script tag
and im using the native applications way of checking the script existence
for example:
{/* Trustpilot Widget */}
<Script
src="//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js"
strategy="afterInteractive"
/>
{/* Trustpilot Widget */}
<Script
src="//widget.trustpilot.com/bootstrap/v5/tp.widget.bootstrap.min.js"
strategy="afterInteractive"
/>
i noticed that on page switch as well sometimes the widget disassperas and fallsback
i current have it in the main root layout of my nextjs app
Sun bearOP
hey @Jerico Aragon sorry to be pinging you curios if im doing something wrong here?
i was using google tag manager to detec the tag on the site and it was failing
Sun bearOP
15.3.3
I'm using the script tag and after interactive strategy
strategy="beforeInteractive"
if you use after, you need to re-run when route change.
Sun bearOP
oho kay
so before interactive is the best way
@Jerico Aragon thank you
still not working on route change like the trust pilot widget disappers
maybe i need to move thse scrips to client components ?