Sync365License Posted November 19, 2022 Share Posted November 19, 2022 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'); 0 Quote Link to comment Share on other sites More sharing options...
SethMcCauley Posted November 28, 2022 Share Posted November 28, 2022 (edited) The code Freshworks provides appears to be JavaScript that is intended to run client-side in the browser. It cannot be executed from the server using PHP in this way. To integrate this code with WHMCS you would need to either 1) use a different hook to insert JavaScript (as a text string) into the page header or 2) modify one or more client area templates to include the custom JavaScript. I think the second option will probably work best for you in this case. Here are a few of the Smarty templates that you might find useful for integrating CRM lead tracking: /templates/six/contact.tpl - contact form (six template)/templates/six/clientregister.tpl - direct client registration (six template)/templates/twenty-one/contact.tpl - contact form (twenty-one template)/templates/twenty-one/clientregister.tpl - direct client registration (twenty-one template)/templates/orderforms/standard_cart/checkout.tpl - client registration during order checkout Note: default template paths are frequently overwritten during WHMCS updates. A child theme should be created and used for any changes to template files such as those listed above. Edited November 28, 2022 by SethMcCauley Additional info on client templates 0 Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.