Insert script with Google Tag Manager

Another way to set up our numbers insertion script includes Google Tag Manager.

First, check if you integrated the web page with Google Analytics using Google Tag Manager.

Here’s how you can do this:

  1. Go to your web page and click on the right button of the mouse and select “View page source”.
  2. When you’ll see the web page code, click on Ctrl+F and enter “” in the search line.
  3. In case you didn’t find it, go to your GTM account and generate the script for your web page. Once you’ve generated it, you can copy it and insert it into your web page code. Here’re some tips for installing your Google Tag Manager code to the web page from Google.
  4. When you’ve set the GTM code to your site, create a new tag for setting Google Analytics on your web page via Google Tag Manager.

If you’ve already set the GTM script and published Google Analytics on your web page, go to the next step and implement the number insertion script by creating a tag for it.

Setting the number insertion script using Google Tag Manager

Step 1: Creating a new variable with the script

First, you should create a new user-defined variable with the script

1. Go to the required workspace and in the Variables menu create a new one by clicking on “New” button.

2. Name the variable with an appropriate title — “Ringostat”.

3. Then select a variable type as Custom JavaScript and copy the adapted numbers insertion script to the HTML-editor.

function () {
  var p = [];
  function _h(){p.forEach(function(a){window.ringostatAnalytics.sendPayload(a.type,a.payload)})};
  function _i(a,b){"loaded"===a.readyState||"completed"===a.readyState?b():setTimeout(function(){_i(a,b)},100)};
  function _c(c,d,a,b){window.ringostatAnalytics||(window.ringostatAnalytics=1,b=c.getElementsByTagName("script")[0],a=c.createElement("script"),a.async=!0,a.src=d,a.onload=_h,_i(a,_h),b.parentNode.insertBefore(a,b))};
  return function (t) {
    if(!0===t.get("ringostatTracker")) return;
    var _o = t.get("sendHitTask");
    t.set("ringostatTracker", true);
    _c(document, 'CLIENT_SCRIPT_URL');
    t.set('sendHitTask', function (m) {
      "object"===typeof window.ringostatAnalytics?window.ringostatAnalytics.sendPayload(m.get("hitType"), m.get("hitPayload")):p.push({type:m.get("hitType"),payload:m.get("hitPayload")});

4. After this, you should change the parameter  SCRIPT_URL to the numbers insertion script link. Go to your project in Ringostat and find the required link in the Insertion scriptScript settings menu.

5. After you found the link to the script, get back to your Google Tag Manager to the variable "Ringostat" you've created before. Find the  SCRIPT_URL parameter in the template of the numbers insertion script, put this link instead of this parameter and save.

Step 2: setting the variable to the running UA tag

Go to your Google Analytics tag > More Settings > Fields to set.

Add the new variable with the numbers insertion script to the UA tag as a new field with the name " customTask"

Once you set all the configurations, publish them on your web page.

In case you need any assistance feel free to contact our Support team via chat or through the email

Is this article helpful?
0 0 0