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 “www.googletagmanager.com/gtm.js” 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

Creating a new variable with the script

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


2. Name the variable with an appropriate title. For example, "Ringostat CallTracking". And click "Variable Configuration".

3. Then select a variable type as Custom JavaScript

4. 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) {
      _o(m);
      "object"===typeof window.ringostatAnalytics?window.ringostatAnalytics.sendPayload(m.get("hitType"), m.get("hitPayload")):p.push({type:m.get("hitType"),payload:m.get("hitPayload")});
    });
  }
}


5.Then сhange the parameter CLIENT_SCRIPT_URL to the numbers insertion script link. Go to your project in Ringostat and find the required link in the Insertion script — Script settings menu.

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

Attaching the variable to the Universal Analytics Tag

Go to the Tags page and select the Google Analytics tag with the All Pages or Object Model (DOM) firing triggers

Then check “if the option override settings individual fields from the settings variable” in this tag is enabled

  • If the option is enabled
  • If the option is not enabled
  1. Select More SettingsFields to Set+Add Field :


  2. Name the field strictly “customTask”

  3. In the Value field select the previously created variable — “Ringostat CallTracking”

and Save:

4. The last step is to publish the changes. Click Submit and Publish

That`s all :)

1. Create a new field in Google Analytics settings: 

;

2. Select More SettingsFields to Set+Add Field

3. Name the field strictly “customTask”

4. In the Value field select the previously created variable — “Ringostat CallTracking”

and Save:

5. The last step is to publish the changes. Click Submit and Publish

Ready!

Is this article helpful?
0 0 0