I am building a white label web application. I need to implement adding custom js code snippet feature ("tags" in marketing terms) to let marketers add tracking code like google analytics code and heap code. In the admin app, admins can add custom js code snippet like this.

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

  gtag('config', 'UA-160375581-1');
</script>

```

As you can see, I need to support both `<script src/>` and `<script>code</script>`.

In the web app (Create-React-App SPA), I need to add this code snippet in the document. I have no idea how to implement this feature.
I tried to inject this code snippet using React dangersoulySetInnerHTML feature. But innerHTML doesn't allow `<script>`.

Please look carefully at the code snippet sample, it also has to support external script specified with `src` attribute.

This screenshot will help you understand what feature I want to implement.

[![screenshot of instapage builder](https://i.stack.imgur.com/mJLzl.jpg)](https://i.stack.imgur.com/mJLzl.jpg)