I think this seems a bit unrelated with the nuxt/scripts as it's more how can you do a tracking in a custom library.
I would suggest maybe using route middleware: https://nuxt.com/docs/getting-sta...
Hey @toniengelhardt
I just checked your reproduction and the data-test does appear in the HTML :thumbnail
![Image](https://github.com/user-attachments/assets/74751cc8-fb62-4145-8e18-3983fdd4656...