Js mini


Cendyn CRM Web SDK is easy to integrate with JS.

Basic Integration

Cendyn CRM Web SDK is easy to set up in your project. You only need to follow the following steps:

  • STEP 1 - To import the library, add the following line in your project in order to include the Cendyn CRM Web SDK.

<script src="https://assets-cdn.pushtech.com/sdk/web/2.0/PUSHTECHWebSDK.2.9.0.min.js" type="text/javascript">

  • STEP 2 - To init the SDK, add in your code at the beginning of execution the following lines of code
var pushSdk = new PUSHTechSDK(your_app_id, your_app_secret,user_id);
   // Correctly registered in Cendyn CRM Platform.
  // Registration failed in Cendyn CRM Platform.

*The function init() return a Promise.
You can get your app_id and app_secret in your personal account of Cendyn CRM Platform in apps section, View App details. The user_id is optional but must be unic as it will make sure that you are not duplicating your contacts, you can use the email or any other identificator.

(Optional) The setOptions methods call before init function and allows to enable or disable the following parameters in the SDK

  • enable_geolocation: If true, send the metric of geolocation when the init function is called. By default: false
  • enable_heartbeat: If true, send a request to the Cendyn CRM server to check if the user is still in webpage. By default: false

Web push Notifications

In order to use Web Push notifications you need to use the lastest version of Cendyn CRM Web SDK, add Service Worker file and check if your app has active flag to manage Web Push Notifications.

Service Worker file:

It is needed to create the js file in the root of web page ( https://www.example.com/pushtech-sw.js) with the code below:
*The name of the file is "pushtech-sw.js" if the name is different it will not work.



The Web SDK provides the functionalities to create specific Metrics to your users details. These metrics are specific for each user, no global users. When you create a metric the function will return a boolean value, if the result is "true" the metric have been created, in case it is "false" this means that the parameters of this function is wrong.

Create Geolocation metric:


This metric will send the geolocation of the user.

Create User metrics

In the following table you will find all the metrics related to the user attributes and user activity.

pushSdk.createBirthdateMetric(new Date());

Date object with date of birth date.


String of the Country ISO code with 2 chars (ISO 3166-1 alpha-2)


String with the city name.


String with the first name.


String with the last name.


String of language in ISO-2


Gender Object (Gender.MALE or Gender.FEMALE);


String with the valid email.


String in E.123 format


When user login in your page.


When user logout in your page.


String with the username to use any user to login in your page.


String with the list id to subscribe contact to the list. (More info: https://www.cendyncrm.com/manager/lists)


String with the list id to unsubscribe contact for the list. (More info: https://www.cendyncrm.com/manager/lists)


Use this metric when user accept your terms and conditions


Use this metric when user accept your marketing consent. The only accepted value is true o false


Use this metric to send what link terms user accept. It is only accepted a string of a link of your Terms and conditions.


Use this metric to send what link of Privacy user accepts. It is only accepted a string of a link of privacy policy.

Create Social metrics

In the following table you will find all the metrics related to the user social activity.


When user login in Facebook.


When user logout in Facebook.


String with the user Facebook ID.


Int number of the user facebook’s friends.


When user login in Twitter.


When user logout in Twitter.

pushSdk.createTwitterIDMetric("Cendyn CRM")

String with the user Twitter ID.


Int number of the user followers in Twitter.


When user login in Google.


When user logout in Google.


String with the user Google ID.

Create Custom metrics

pushSdk.createCustomMetric("CUSTOM_KEY", "VALUE", ValueType.STRING);

You can track any events by using custom metric method. The "createCustomMetric" function required three parameters:

  • Custom Key: Use the same key of our custom fields created in the Cendyn CRM platform: https://www.cendyncrm.com/settings/custom_fields
  • Value: Any object like String, Number, Boolean or Date (Date in ISO_8601, Example: 1990-01-01T00:00:00Z).
  • ValueType: Specific type of value to be sent. If the value object is different of ValueType the metric will no be created. Types: STRING, NUMBER, BOOLEAN, DATE

Create Custom Counter metrics

pushSdk.createCounterCustomMetric("CUSTOM_KEY", Value);

You can track the number of times an event occurs. The "createCounterCustomMetric" function required Two parameters:

  • Custom Key: It is needed a custom field with the type Number created in the Cendyn CRM platform: https://www.cendyncrm.com/settings/custom_fields. The valor passed will increment the total value of the custom field.
  • Value: Only allowed number type.

Create Purchase metrics

Cendyn CRM Web SDK allows you to track every purchase it is made in your eCommerce.

For each product that have been added, removed, purchased, refunded or purchase failed you must created a Product object:

var product = new Product();
product.productId = "2302323232-2321323-2-23";                        //required
product.name = "Ball";                                                //required
product.price = 10.5;                                                 //required
product.currency = "EUR";                                             //required
product.description = "Description product";                          //optional
product.url = "https://www.example.com/products/1";                   //optional
product.image_url = "https://www.example.com/products/1/image.jpg";   //optional
product.transaction_code = "_238974982_32_32";                        //optional Transaction ID

If you need extra information for yours products, you can create variable products at: https://www.cendyncrm.com/manager/product_custom_fields and use it like product fields

ADD product in cart:


Remove product from the cart:


Refund product purchase:


Failed product purchase:


When the user purchase several products you should create an another object to add all products in one metric:

var products = new Products();

Send metrics


You can decide when to send metrics to the Cendyn CRM Platform. If you create metrics but never call this method the metrics will not be send to the server.

The metrics are stored in the browser localStorage, when you call this method it will automatically retrieved from localStorage and send it. The metrics will be updated in few seconds and you can visualize the changes in contact details section of Cendyn CRM Platform.