• Features
  • API Docs
  • Help Center
  • Log in
  • Sign Up
  • Features
  • API Docs
  • Help Center
  • Log in
  • Sign Up

JS script & Google Tag Manager

370 views July 28, 2020 0

Google Tag Manager– is a solution from Google that allows you to place custom scripts on site pages without directly interfering with its code.

Content-control software or web filtering software – a device or software for filtering sites by their content, which does not allow access to certain sites or services on the Internet. The system allows you to block websites with content that is not intended for viewing.

How to use a script to add and update contacts through Google Tag Manager

Step-by-step instructions:

    1. Add a site to add/update contacts to your SmartSender account.
    2. Download the installation file. IMPORTANT: Upload it to the top level directory of your site.
    3. Create a new tag in your Google Tag Manager account.
    4. Select the type of Custom HTML tag.
    5. In the “HTML” field in the “Tag Configuration” form, add the script

    6. Configure the triggers that will activate the tag.
    7. Save the tag. Submit your workspace changes to Google Tag Manager
    • If you pass empty values ​​of variables
      var initConfig = {};
      var cac = {};
      var variables = {};
      
      if ('{{userId}}' !== 'undefined') {
          initConfig['userId'] = '{{userId}}'
      }
      if ('{{email}}' !== 'undefined') {
          initConfig['email'] = '{{email}}'
      }
      if ('{{phoneNumber}}' !== 'undefined') {
          initConfig['phoneNumber'] = '{{phoneNumber}}'
      }
      if ('{{contactName}}' !== 'undefined') {
          initConfig['name'] = '{{contactName}}'
      }
      if ('{{sourceId}}' !== 'undefined') {
          initConfig['source'] = '{{sourceId}}'
      }
      if ('{{value}}' !== 'undefined') {
          cac['value'] = '{{value}}'
      }
      if ('{{currency}}' !== 'undefined') {
          cac['currency'] = '{{currency}}'
      }
      if ('{{stringVariableFromList}}' !== 'undefined') {
          variables['stringVariableFromList'] = '{{stringVariableFromList}}'
      }
      if ('{{dateVariableFromList}}' !== 'undefined') {
          variables['dateVariableFromList'] = '{{dateVariableFromList}}'
      }
      if ('{{newTestVariable}}' !== 'undefined') {
          variables['newTestVariable'] = '{{newTestVariable}}'
      }
      initConfig['cac'] = cac;
      initConfig['variables'] = variables;
      var sSmartSenderData = initConfig;
      
    • If you use symbol values ​​of variables
      if("{{stringVariableFromList}}"!=="false" && "{{stringVariableFromList}}"!=="undefined") {
         variables["stringVariableFromList"]="{{stringVariableFromList}}";
      }
      

      If you pass symbols in variables, your browser can pass them as “false”, in order to prevent variables from changing to false use the following example script.

Similar posting
  • How to Enable and Disable Web Push Notifications in Google Chrome
  • How to Install JS API
  • Web Push Log
  • Push Notifications & Google Tag Manager
  • Web Push Campaigns
  • Web Push Template Preview
Company
  • About us
  • Team
  • YouTube
  • Facebook
  • Google Business
Legal
  • Terms of Use
  • Privacy Policy
  • Anti-Spam Policy
  • Cookie Statement
Resources
  • Api Documentation
  • FAQ
  • Knowledge Base
  • SmartSender Blog
  • Marketplace

We use cookies to make SmartSender’s website a better place. Cookies help to provide a more personalized experience for you, and web analytics for us. To learn more, and to see a full list of cookies we use, check out our Cookie Policy (baked goods not included).

got it