Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong GA script injection - script is inserted in the body as text #699

Open
voiceapiai-dev opened this issue May 18, 2024 · 0 comments · May be fixed by #700
Open

Wrong GA script injection - script is inserted in the body as text #699

voiceapiai-dev opened this issue May 18, 2024 · 0 comments · May be fixed by #700

Comments

@voiceapiai-dev
Copy link

hi
first of all - thanks for this tool and OSS contributions

Desctiption

today I've decided to use it for my project https://github.com/voiceapiai/ralertsinua, and when I configured analytics settings I found that google tag script injection is broken - script is inserted in the body as text

image

How to reproduce:

  • remote: find broken script text visible at https://voiceapiai.github.io/ralertsinua/ at the very bottom of the screen
  • local - add analytics configuration according to the docs, run oranda build, find broken injection in generated index.html - script is inserted in the body as text

Possible solution:

according to Google, this is the code one need to insert at the website (notice 2 script tags):

<!-- Google tag (gtag.js) -->
<script async src="https://www.googletagmanager.com/gtag/js?id=G-TCJ5D14XV4"></script>
<script>
  window.dataLayer = window.dataLayer || [];
  function gtag(){dataLayer.push(arguments);}
  gtag('js', new Date());

  gtag('config', 'G-TCJ5D14XV4');
</script>

but this line

format!("window.dataLayer = window.dataLayer || []; function gtag(){{dataLayer.push(arguments);}} gtag('js', new Date());gtag('config', '{}');", self.tracking_id)

doesn't have HTML <script> tag, and thus the string is being inserted directly in the body

if possible, I would like to contribute and help to solve this issue

voznik added a commit to voiceapiai/oranda that referenced this issue May 18, 2024
@voznik voznik linked a pull request May 18, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant