Versions Compared
Version | Old Version 1 | New Version Current |
---|---|---|
Changes made by | ||
Saved on |
Key
- This line was added.
- This line was removed.
- Formatting was changed.
Main script
Place this script on all public pages of the site inside the <head> element.
Initialization
Initialize the SDK object and use it anywhere in your application.
Warning |
---|
Remember to initialize the SDK only once on application launch. |
Code Block | ||||
---|---|---|---|---|
| ||||
<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.
Code Block | ||||
---|---|---|---|---|
| ||||
personaclick("init", store_key, success, errorimport PersonaClick from '@personaclick/rn-sdk'; ... const pcsdk = new PersonaClick(store_key, stream, debug, send_token); |
Initialization parameters
Name | Type | Requirement | Description |
---|---|---|---|
store_key | string | required | The current store key from the PersonaClick account. |
stream | string | required | Data stream code. Alphanumeric string (letters, numbers only). Max length: 16. It can be "ios", "android", or any other string value. It's used to distinguish between mobile apps, websites, and other events sources. |
debug | boolean | optionally | Allows debugging info to be displayed in the console. Default: false. |
send_token | boolean | optionally | Allows managing the automatic getting of Firebase/APNs token and sending it to the system. Default: true. |
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
personaclick("initimport PersonaClick from '@personaclick/rn-sdk'; ... const pcsdk = new PersonaClick("c6d2fe5fdca0c8e51d10b07523bc07", "c6d2fe5fdca0c8e51d10b07523bc07android", function()false, true); |
Initialization Check
The method allows checking if the initialization is done or not.
Method Response
The method returns a boolean value:
- true - initialization completed
- false - initialization failed or ended with an error
Example of use
Code Block | ||||
---|---|---|---|---|
| ||||
if (pcsdk.isInit()) { // Do something in case of successfulthe initialization console.log("The PersonaClick initialization was successful"); }, function()else { // Do something in case of unsuccessful the initialization failed or ended console.log("The PersonaClick initialization was unsuccessful"); });with an error } |
Column | ||||
---|---|---|---|---|
Page Navigation
|
Related Pages
|