Page Layout

PHP Library

Modified on: Wed, 23 Mar, 2016 at 4:58 PM


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


STEP 1: Getting started

To install the library you must,

  1. Download the latest version of Freshsales Analytics.zip (analytics-1.0.0..zip) 
  2. Include FreshsalesAnalytics.php  in your application 
  3. Instantiate the core analytics class FreshsalesAnalytics with the snippet below
FreshsalesAnalytics::init(array(
‘domain’ => "<APP URL>", 
‘app_token’ => "<APP TOKEN>" 
);

      4. Replace the "<APP URL>"and "<APP TOKEN>" with your portal url and app token. You can find it under Admin Settings > Integrations > Freshsales for web > PHP



STEP 2: Create leads

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

FreshsalesAnalytics::identify(array(
   'identifier' => "john@abc.com",
   'Last name' => "Doe",
   'company' => array(
      'Name' => "Test Company"
   )
));

 


STEP 3: Create contacts

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

FreshsalesAnalytics::identify(array(
   'identifier' => "john@abc.com",
   'Last name' => "Doe",
   'fs_contact' => true,
   'company' => array(
      'Name' => "Test Company"
   )
));

 


STEP 4: Track Pageviews

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

FreshsalesAnalytics::trackPageView(array(
  'identifier' => ‘john@abc.com', //Identifier
   'url' => 'http://sample.com/pricing' //Track Page URL ));

 



STEP 5: 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. 
FreshsalesAnalytics::trackEvent(array(
   'identifier' => ‘john@abc.com', //Identifier
   'name' => 'Inviting New User', //Event Name
   'user_email' => 'user@abc.com', //Custom Property 1
   'prop2' => 'value2' //Custom Property 2
));

 



STEP 6: Update lead and contact information

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

To update lead/contact information, 

  1. Call  FreshsalesAnalytics::identify from the snippet below.
FreshsalesAnalytics::identify(array(
   ‘Identifier’ => ‘john@abc.com’,
   contactPayment => array(
‘Payment Id’ => 129863,
‘Plan Name’ => ‘2 agents’,
‘Amount’ => ‘$2500’,
‘CustomField’ => ‘Custom Field Value’
)
));

 If your web form has fields that aren’t in Freshsales, you can create custom fields for the same and get the values pushed to Freshsales. 




Freshsales.zip Freshsales.zip

(10.7 KB)


Did you find it helpful? Yes No

Can you please tell us how we can improve this article?

Sign up for Freshsales today

Start your 21-day free trial. No credit card required. No strings attached.

Start Free Trial

PHP Library

Modified on: Wed, 23 Mar, 2016 at 4:58 PM


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


STEP 1: Getting started

To install the library you must,

  1. Download the latest version of Freshsales Analytics.zip (analytics-1.0.0..zip) 
  2. Include FreshsalesAnalytics.php  in your application 
  3. Instantiate the core analytics class FreshsalesAnalytics with the snippet below
FreshsalesAnalytics::init(array(
‘domain’ => "<APP URL>", 
‘app_token’ => "<APP TOKEN>" 
);

      4. Replace the "<APP URL>"and "<APP TOKEN>" with your portal url and app token. You can find it under Admin Settings > Integrations > Freshsales for web > PHP



STEP 2: Create leads

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

FreshsalesAnalytics::identify(array(
   'identifier' => "john@abc.com",
   'Last name' => "Doe",
   'company' => array(
      'Name' => "Test Company"
   )
));

 


STEP 3: Create contacts

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

FreshsalesAnalytics::identify(array(
   'identifier' => "john@abc.com",
   'Last name' => "Doe",
   'fs_contact' => true,
   'company' => array(
      'Name' => "Test Company"
   )
));

 


STEP 4: Track Pageviews

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

FreshsalesAnalytics::trackPageView(array(
  'identifier' => ‘john@abc.com', //Identifier
   'url' => 'http://sample.com/pricing' //Track Page URL ));

 



STEP 5: 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. 
FreshsalesAnalytics::trackEvent(array(
   'identifier' => ‘john@abc.com', //Identifier
   'name' => 'Inviting New User', //Event Name
   'user_email' => 'user@abc.com', //Custom Property 1
   'prop2' => 'value2' //Custom Property 2
));

 



STEP 6: Update lead and contact information

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

To update lead/contact information, 

  1. Call  FreshsalesAnalytics::identify from the snippet below.
FreshsalesAnalytics::identify(array(
   ‘Identifier’ => ‘john@abc.com’,
   contactPayment => array(
‘Payment Id’ => 129863,
‘Plan Name’ => ‘2 agents’,
‘Amount’ => ‘$2500’,
‘CustomField’ => ‘Custom Field Value’
)
));

 If your web form has fields that aren’t in Freshsales, you can create custom fields for the same and get the values pushed to Freshsales. 




Freshsales.zip Freshsales.zip

(10.7 KB)


Did you find it helpful? Yes No

Can you please tell us how we can improve this article?

Sign up for Freshsales today

Start your 21-day free trial. No credit card required. No strings attached.

Start Free Trial