Integrate SDK

This page will give detailed description of how you can integrate Growlytics javascript SDK to your website.

Step 1: Install SDK

Copy-paste the following code into <head> of your application's root page. Make sure this script is added on all the pages of your website or web app.

<script>
let growlyticsSettings = {
apiKey: '<api_key>',
enabled: true
};
var g = { input: growlyticsSettings, q: [] };var t=["events.track","user.identify","user.push","showMessage","requestNotificationPermission","cart.sync"];for(let e=0;e<t.length;e++){let s=t[e].split("."),i=function(...s){g.q.push({a:t[e],p:s})};if(s.length>0){let t=s[0],e=s[1];g[t]=g[t]?g[t]:{},g[t][e]=i}else g[s[0]]=i}
window['Growlytics'] = g;
function(){var t=document.createElement("script");t.type="text/javascript",t.async=!0,t.src=("https:"==document.location.protocol?"https://static.growlytics.in":"http://static.growlytics.in")+"/growlytics.min.js",t.src="/dist/growlytics.js";var c=document.getElementsByTagName("script")[0];c.parentNode.insertBefore(t,c)}();
</script>

growlyicsSettings method supports following parameters.

Option

Type

Description

apiKey

string

Api Key for given project. You can find the api key in project settings page.

enabled

boolean

Enable/disable growlytics sdk.

Step 3: Track Events

Let's suppose we want to track an event "Product Viewed" when a customer views a product. To track this event, you can use Growlytics.events.track() method.

With event name, you can pass custom JSON that you can later use for analytics and engagement purpose.

Growlytics.events.track("Product viewed",{
'Product Name': 'Macbook Pro 2020',
'Category': 'Electronics',
'SubCategory': 'Laptops',
'Price': 139000,
'Brand': 'Apple'
});

Growlytics supports Number, BigInt, String, Boolean and Date data types for event property values. For further details refer to event tracking considerations.

Step 3: Further Integrations

For further integrations, please refer to individual sections.