The PHP Library helps you track the in-app activities of your customers using your web application.


Getting started

To install the library you must,

  1. Download the latest version of ( 

  2. Include FreshsalesAnalytics.php  in your application 

  3. Instantiate the core analytics class FreshsalesAnalytics with the snippet below


‘domain’ => "<APP URL>",

‘app_token’ => "<APP TOKEN>"


  1. Replace the "<APP URL>"and "<APP TOKEN>" with your portal url and app token. You can find it under Admin Settings > CRM Code Library > PHP

Create contacts 

You can use the snippet below to create contacts, track signups and logins. 


  'identifier' => "",

  'Last name' => "Doe",

  'fs_contact' => true,

  'company' => array(

     'Name' => "Test Company"



Track Pageviews

You can track the pages viewed in your application using the snippet below.


 'identifier' => ‘', //Identifier

  'url' => '' //Track Page URL ));

Track Events

You can use the snippet below to track all the in-app activities of your users like - adding users, enabling/disabling integrations, password resets, number of logins etc as Events in Freshsales.

To track events, 

  1. Identify the specific call to action buttons that you’d like to be notified about. 

  2. Call the trackEvent method from the snippet below. 


  'identifier' => ‘', //Identifier

  'name' => 'Inviting New User', //Event Name

  'user_email' => '', //Custom Property 1

  'prop2' => 'value2' //Custom Property 2


Update contact information

The library also updates contact information through web forms and visitor activity on the web app. 

To update contact information, 

  1. Call  FreshsalesAnalytics::identify from the snippet below.


  ‘Identifier’ => ‘’,

  contactPayment => array(

‘Payment Id’ => 129863,

‘Plan Name’ => ‘2 agents’,

‘Amount’ => ‘$2500’,

‘CustomField’ => ‘Custom Field Value’



Create custom fields to capture information that cannot the captured using the default fields.