Initialization (JS SDK)
- Andrey Veprikov
Main script
Place this script once on all public pages of the site inside the <head> element.
Don't forget to replace the %YOUR_STORE_KEY% text with the current store key from your PersonaClick account.
The initialization should be done only once per page. Repeated initializations on the same page will fail and stop the JS SDK work.
<script> (function(){ window.personaclick=window.personaclick||function(){(window.personaclick.q=window.personaclick.q||[]).push(arguments)}; var c="//cdn.personaclick.com",v="/v3.js",s={link:[{href:c,rel:"dns-prefetch"},{href:c,rel:"preconnect"},{href:c+v,rel:"preload",as:"script"}],script:[{src:c+v,async:""}]}; Object.keys(s).forEach(function(c){s[c].forEach(function(d){var e=document.createElement(c),a;for(a in d)e.setAttribute(a,d[a]);document.head.appendChild(e)})}); })(); personaclick("init", "%YOUR_STORE_KEY%"); </script>
Additional Features
The initialization method has additional features - callback functions for success and error states.
personaclick("init", store_key, stream, success, error, cookieless);
Initialization parameters
Name | Type | Requirement | Description |
---|---|---|---|
store_key | string | required | The current store key from the PersonaClick account. |
stream | string | optionally | Data stream code. Alphanumeric string (letters, numbers only). Max length: 16. The empty default value will mean "web". Can be "ios", "android" or any other string. Used to distinguish between mobile apps, websites, and other events sources. |
success | function | optionally | The function will be executed after successful initialization. |
error | function | optionally | The function will be executed after unsuccessful initialization (any Personaclick API response other than 200). |
cookieless | boolean | optionally | Allows the SDK to use the browser's local storage instead of cookies. Default: false. If Local Storage is used, the session duration is 24 hours and is not affected by closing a browser, as is the case with session cookies. |
Example of use
personaclick("init", "c6d2fe5fdca0c8e51d10b07523bc07", "web", function() { // Do something in case of successful initialization console.log("The PersonaClick initialization was successful"); }, function() { // Do something in case of unsuccessful initialization console.log("The PersonaClick initialization was unsuccessful"); }, true);
Page Navigation
Related Pages
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
-
Page:
Copyright 2018-2024 PersonaClick