Comment pouvons nous vous aider ? 👋

Javascript integration (English version)

1. On all the website pages

Insert the next code on all the website pages, before the end tag ”</body>”.

<script>
	// Configuration du tracker SPREAD
	var spconfig = {
	    public_key: "PUBLIC_KEY", // To be replaced by the public API key
	    debug: false,
	    set_cookie: true
	};
	
	// Méthode de chargement du tracker
	function loadSpreadTracker(){window.domLoadEventFired=!0;var a=document.createElement("script");a.type="text/javascript",a.async=!0,a.charset="UTF-8",a.id="spread-tracker",a.src="//static-sb.com/js/sb-tracker.js",document.body.appendChild(a)}window.addEventListener?window.addEventListener("load",loadSpreadTracker,!1):window.attachEvent?window.attachEvent("onload",loadSpreadTracker):window.onload=loadSpreadTracker;
</script>
 

The Spread javascript allows :

  • to set up widgets on your website,
  • to place the tracking cookie on the browser of the user of your site.

The Spread javascript was designed to not slow down the display of your pages and guarantees you seamless operation.

Details of the object configuration spconfig

  • public_key : Your public key is available in the back-office tab Intégration > Tracker > Clés API.
  • debug : true/false Allows to display the logs in the console.
  • set_cookie : true/false Allows you to assign a cookie to clients.

2. Account creation feedback

The following code is to be inserted on the account creation confirmation page in the footer, in addition to the tag on all pages and before the function loadSpreadTracker.

var spconfig = {...};

var sporder = {
    email: "xxx@xxx.xxx",
    external_id: "xxxxxx",
    name: "doe", //If you do not specify this parameter we will insert the beginning of the email
    firstname: "john",
    optin: 1, // 1:optin / 0:not optin / -1: unknown
    country : "FR",
    birthday : "1970-12-31", // format: YYYY-MM-DD
    gender : "male", // "male" or "female"
    address : "8, rue de la place",
    address_2 : "bâtiment A",
    address_3 : "appartement 23",
    cp : "76000",
    city : "Rouen",
    tel : "0235000000",
    mobile : "060606606",
    fonction : "developer",
    company : "SPREAD",
    lang : "fr_FR",
    action : "signup", // "signup" = Création de compte; "order" = Création de commande; "newsletter" = Inscription à la NL
    add_tag : ["tag1", "tag2", "tag3"], // Ajout de tags sur le profil (Add tags on profile)
    del_tag : ["tag2", "tag4"], // Suppression de tags sur le profil (Delete tags on profile)
    custom_fields: {
      5874: "value" // Id du custom_field. 
    }
};

function loadSpreadTracker(){...};

3. Relaying of orders

This JavaScript allows orders and customer information to be automatically uploaded to SPREAD's CRM when they place an order on your site.

The following code is to be inserted on the order confirmation page in the footer, in addition to the tag on all pages and before the function loadSpreadTracker.

To do this, simply add the order information to the sporder object configured above.

var spconfig = {...};

var sporder = {
    email: "johndoe@sb.am",
    state: "10", // 10: taked / 20: paid / 50: sent / 100: received
    amount: "158.31",
    idorder: "0000001",
    date: "2014-06-21 14:31:08", // Date of the order in YYYY-MM-DD hh:mm:ss (UTC)
    start_service: "2019-06-15", // Start date of the service in YYYY-MM-DD (UTC)
    end_service: "2019-06-26", // End date of the service in YYYY-MM-DD (UTC)
    add_order_tag : ["tag_commande_1", "tag_commande_2"], // Adding tags to the order
    del_order_tag : ["tag_commande_3", "tag_commande_4"], // Removal of tags on the order
    product_attributes: [
        ["size:xl", "type:shirt"], // Product attributes 1
        ["size:s", "color:blue"], // Product attributes 2
    ],
    // product_attributes: [] // Leave empty to remove all attributes
    // product_attributes: null // null does not trigger any changes
    action: "order",
};

function loadSpreadTracker(){...};

Correspondence Order status

  • 0 : cancelled orders These orders are not included in the sales figures.
  • 10 : status of orders for which payment has not yet been validated These orders do not count towards sales unless you configure it in the SPREAD BackOffice "Paramétrage > Tracker > Statut de commande"
  • 20 status of paid orders
  • 50 : status of shipped orders
  • 100 : status of completed orders, with payment made and order delivered to customer
 
Notion image
 
 

Management of the idorder value

The idorder value is the unique identifier of the order on the store.

The first time this identifier is used, the order is recorded in the CRM. If the order id is presented a second time, the data is updated.

This identifier is especially useful for changing the status of the order (canceling it or putting it on shipment).

Opt-in & Consent

The account and order escalation scripts allow you to retrieve the newsletter / SMS subscriptions made during an account creation or an order.

They use respectively the following parameters:

  • optin
  • mobile_optin

Cookie et RGPD

If you want to trigger the tracker only after validating the consent of your user you can follow the following explanations.

 
var spconfig = {...};

// Disable SPREAD tracker auto-run
window.spAutoload = false;

function loadSpreadTracker(){...};

// Loading widgets as soon as possible
// Note that this code will also report account/order creation if the sporder variable is available
window.addEventListener("SPREAD_ready", function() {
		SPREAD.launch({widgets : true});
});

Details of the method Spread.launch

// Initialize widgets and set cookie `spw`
// Since this is the first call, it will also do the command forwarding if `sporder` is set.
SPREAD.launch({widgets : true});

// Initialize and set the cookie `sbt`
// This will have no impact on the widgets and the cookie `spw`
SPREAD.launch({tracker : true});

// Ne va avoir aucun effet
SPREAD.launch();

// Delete all widgets and the cookie `spw`
// This will have no impact on the cookie `sbt`
SPREAD.launch({widgets : false});

// Load widgets + cookie `spw` and deletes the cookie `sbt`
SPREAD.launch({widgets : true, tracker : false});
 
 
🆘
Si vous avez d’autres questions sur ce sujet, vous pouvez contacter le support. 💬
Cela a-t-il répondu à votre question ?
😞
😐
🤩