Hey All,
Really struggling to work out how I can execute the script for FreshSales suite.
I want to create the contact on clientAdd, but cannot work it out.
The info for it is here: How to set up Freshworks CRM Tracking Code? : Freshsales Suite
From what I understand, the tracking code loads a jquery library, and the code to create the contact uses that to make the contact.
I just cannot work out how to get it to work via the hook
Any help appreciated.
Here is what i have
<?php
if (!defined('WHMCS'))
die('You cannot access this file directly.');
function create_fs_contact($vars) {
var new_contact =
{
"First name": $vars['firstname'], //Replace with first name of the user
"Last name": $vars['lastname'], //Replace with last name of the user
"Email": $vars['email'], //Replace with email of the user
"Alternate contact number": $vars['phonenumber'], //Replace with a custom field
"company": {
"Name": $vars['companyname'], //Replace with company name
"Website": array_pop(explode('@', $vars['email'])) //Replace with website of company
}
};
var identifier = $vars['email'];
fwcrm.identify(identifier, new_contact)
}
add_hook('ClientAdd', 1, 'create_fs_contact');