Configuration
How to alter the settings of Clerk.js.
Configuring Clerk.js
Clerk.js is configured by default
If you use one of your plugins, or copy-paste the tracking code from my.clerk.io, Clerk.js is already configured.
This is only for if you need more advanced customisation.
The object can be configured by the Clerk('config',' ') method with the following options as a object parameter:
Option | Purpose |
---|---|
key | Your store's public API key. |
visitor | The visitors ID, used for tracking purposes. Can be set to 4 modes: - auto is default, and will also be used if visitor is not set. This mode is fully cookieless and generates a unique, anonymous ID based on IP and user-agent, that is used for up to 30 days. If explicitly set, the tracking cookie set by Clerk.io will be removed if it exists.- persistent causes Clerk.js to generate a unique ID that is stored in a long-time identifier cookie.- CUSTOM_ID let's you generate and configure unique IDs for visitors. Replace CUSTOM_ID with the actual ID per visitor as a string.- null completely stops any website tracking during the session. Also removes Clerk.io tracking cookie if it exists. |
language | Global configuration of the language to be used if applying multiple languages. This will be auto detected by default from the page's language meta information. |
collect_email | true if Clerk.js should automatically detect emails from input fields, else false . This is used for ie. abandoned basket and other personalized emails. false by default. |
formatters | A mapping of custom template formatters |
globals | A mapping of custom values or functions that should be available in all Templates. |
auto_init_custom_selectors | Clerk.js automatically initialises any elements with the class "clerk" both during initial pageload and when the DOM is mutated. When true , Clerk.js will initialise any elements with custom selectors that have been already been rendered with Clerk("content", "SELECTOR") as the DOM mutates. This behaviour continues until a full page refresh happens.Defaults to false where all elements with custom selectors renders when Clerk("content", "SELECTOR") is run. |
debug | Debug configuration. By default, all errors and warnings will be logged to the browser's console and to your store log on my.clerk.io if possible. Read more about this configuration under Debugging. |
Multiple configuration calls will only update the given configuration options and leave the others intact
When adding or editing configurations, it takes a dictionary as follows:.
Clerk('config', {
key: 'YOUR_API_KEY',
visitor: 'ABC123',
language: 'english',
collect_email: true,
formatters: {
format_price: function(price) {
return price.toFixed(2).toString();
},
uppercase: function(string) {
return string.toUpperCase();
}
},
globals: {
currency_symbol: '$',
return_price: function(price_list) {
if (customer_group = 1) {
return price_list[1];
}
else {
return price_list[0];
}
}
},
debug: {
enable: true,
level: 'warn',
collect: true
}
});
Clerk can also be configured for live testing by using url parameters. Using a # at the end of url and clerkjs: you can change all elements of the configuration. For example, the debugger can be enabled by entering #clerkjs:debug.ui=on at the end of the url address.
Updated 9 days ago