1.0.1 • Published 2 years ago

stape-sgtm-nodejs v1.0.1

Weekly downloads
-
License
Apache-2.0
Repository
-
Last release
2 years ago

Stape sGTM NodeJS SDK

Getting Started

Configuration

Fill in the basic parameters:

import StapeSGTM, { transformations, EventData } from 'stape-sgtm-nodejs';

const sgtm = new StapeSGTM({
   gtm_server_domain: 'https://gtm.stape.io',
   request_path: '/data',
 });
VariableDescription
gtm_server_domainServer host
request_pathRequest processing path

Sending Event Data

sgtm.sendEventData(<eventName>, <eventData>);
VariableDescription
eventNameEvent name
eventDataArray of options for forming event data

eventData

const eventData = [{
  page_hostname: 'Stape',
  page_location: 'http://stape.io',
}]
OptionDescription
nameVariable name
valueVariable value

Transformations

OptionDescription
trimRemoves whitespace from the beginning and end of the value
base64Encodes the string in Base64 format
md5Encodes the string in MD5 format
sha256base64Encodes the string in SHA256 Base64 format
sha256hexEncodes the string in SHA256 HEX format

Full Example

import StapeSGTM, { transformations, EventData } from 'stape-sgtm-nodejs';

const sgtm = new StapeSGTM({
  gtm_server_domain: 'https://gtm.stape.io',
  request_path: '/data',
});

const eventData: EventData = {
  client_id: '123456',
  currency: 'USD',
  ip_override: '79.144.123.69',
  language: 'en',
  page_encoding: 'UTF-8',
  page_hostname: 'Stape',
  page_location: 'http://stape.io',
  page_path: '/',
  user_data: {
    sha256_email_address: transformations.sha256hex('jhonn@doe.com'),
    phone_number: '123456769',
    address: {
      first_name: 'Jhon',
    },
  },
};

sgtm
  .sendEventData('page_view', eventData)
  .then((result) => console.log('🚀 ~ file: simple.ts:19 ~ result:', result))
  .catch((error) => console.log('🚀 ~ file: simple.ts:21 ~ error:', error));
1.0.1

2 years ago

1.0.0

2 years ago