title: Where should analytics script be put in a React app?
body: <p>Barion Pixel requires to put in code in my React app. When I put it in <code>App.js</code> or <code>index.js</code>, it raise an error. Do you have any idea where to put it? In index.html inhas no effect. Strange.</p>
  
  <p><a href="https://docs.barion.com/Implementing_the_Base_Barion_Pixel" rel="nofollow noreferrer">https://docs.barion.com/Implementing_the_Base_Barion_Pixel</a></p>
  
  <pre><code>&lt;script&gt;
          // Create BP element on the window
          window["bp"] = window["bp"] || function () {
              (window["bp"].q = window["bp"].q || []).push(arguments);
          };
          window["bp"].l = 1 * new Date();
  
          // Insert a script tag on the top of the head to load bp.js
          scriptElement = document.createElement("script");
          firstScript = document.getElementsByTagName("script")[0];
          scriptElement.async = true;
          scriptElement.src = 'https://pixel.barion.com/bp.js';
          firstScript.parentNode.insertBefore(scriptElement, firstScript);
  
          // Send init event
          bp('init', 'addBarionPixelId', 'BP-0000000000-00');
      &lt;/script&gt;
  </code></pre>
  
  <p>I just show how error looks like:</p>
  
  <p><a href="https://i.stack.imgur.com/m8sE7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/m8sE7.png" alt="enter image description here"></a></p>