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,
Download the latest version of Analytics.zip (analytics-1.0.0..zip)
Include FreshsalesAnalytics.php in your application
Instantiate the core analytics class FreshsalesAnalytics with the snippet below
FreshsalesAnalytics::init(array(
‘domain’ => "<APP URL>",
‘app_token’ => "<APP TOKEN>"
);
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.
FreshsalesAnalytics::identify(array(
'identifier' => "[email protected]",
'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.
FreshsalesAnalytics::trackPageView(array(
'identifier' => ‘[email protected]', //Identifier
'url' => 'http://sample.com/pricing' //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,
Identify the specific call to action buttons that you’d like to be notified about.
Call the trackEvent method from the snippet below.
FreshsalesAnalytics::trackEvent(array(
'identifier' => ‘[email protected]', //Identifier
'name' => 'Inviting New User', //Event Name
'user_email' => '[email protected]', //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,
Call FreshsalesAnalytics::identify from the snippet below.
FreshsalesAnalytics::identify(array(
‘Identifier’ => ‘[email protected]’,
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.