=== ITPS CRM ===
Contributors: ahmedadmin
Tags: crm, live chat, visitor tracking, gravity forms, sms consent
Requires at least: 5.8
Tested up to: 7.1
Requires PHP: 7.4
Stable tag: 1.0.1
License: GPLv2 or later
License URI: https://www.gnu.org/licenses/gpl-2.0.html

Connects your site to ITPS CRM: optional webchat and visitor tracking, plus Gravity Forms entries with SMS consent sent to the CRM.

== Description ==

Paste one key. Everything else follows.

**This plugin requires an ITPS CRM account.** It is the WordPress end of a hosted service; on its own, with no CRM address and site key entered, it does nothing at all. See *External services* below for exactly what is sent where.

**Webchat and visitor tracking — off until you switch it on.** One tick-box on the settings page puts the chat bubble on every page, and the same script tells the CRM who is on the site right now and what they are reading — not only the people who click the chat. Nothing is loaded and no visitor data is sent until an administrator ticks that box. No snippet to paste into a theme, so it survives theme updates and can be switched off again without editing PHP.

**Gravity Forms.** Every form gains an *ITPS CRM* feed. The mapping screen has your CRM's own fields down the left — including custom fields you added there — because the list is fetched from your workspace rather than hard-coded. Add a field in the CRM, press *Check again* on the settings page, and it is in the dropdown.

**SMS consent that is actually a record.** Map *SMS Marketing Consent* to a Gravity Forms **Consent** field and what reaches the CRM is not a bare `true`. It carries:

* whether the box was ticked,
* the label exactly as it read at that moment,
* the full consent wording *as it was on the day* — Gravity Forms keeps a revision of it, because form text gets edited,
* the visitor's IP address, the page they submitted from, their browser, and the form and entry number.

That is the difference between "the box was ticked", which proves nothing, and being able to answer the only question a complaint actually asks eighteen months later: what exactly did this person agree to, and where is it written down.

A plain checkbox works too, and is recorded honestly as what it is — the label is kept, but with no revision history behind it, so the wording is whatever the field says today.

Once consent is on file, the CRM can send a welcome text by itself: in the CRM, **Automations → when "Someone agrees to be texted"**. It is the one message you are certainly allowed to send, and the moment they are most expecting it.

== External services ==

This plugin connects to ITPS CRM, a hosted CRM service, at the address you enter on the settings page. The default address is `https://itpscrm.com`; if you run the CRM on your own domain, that is the address it talks to instead. Nothing is sent anywhere until you enter a CRM address and a site key, and the plugin has no other network destination.

There are three separate connections, and they are all listed here.

**1. Connecting the site (admin only).**
When you press Save on **Settings → ITPS CRM**, or press *Check again / refresh field list*, the plugin makes a request to `https://itpscrm.com/api/site_link.php` carrying your site key. It sends the site key and nothing else, and receives back the workspace name, the chat widget key, and the list of field names in your workspace so the Gravity Forms mapping dropdown can be filled in. This happens only when an administrator saves or refreshes the settings — never on a front-end page load.

**2. The chat and visitor-tracking script (every front-end page, only when switched on).**
This is **off by default**. Only when an administrator ticks *Load the ITPS CRM chat widget and report visitors to the CRM* and the site is connected does each front-end page load a JavaScript file from `https://itpscrm.com`. That script runs in the visitor's browser and reports page views to ITPS CRM so that the CRM can show who is on the site and what they are reading, and so the chat bubble can carry a conversation. What it sends is the page URL, the referrer, the browser user agent and the visitor's IP address (which any web request carries), plus anything the visitor types into the chat. Leave the box unticked, or untick it, and no script is loaded and nothing is sent from front-end pages.

**3. Form entries (only for forms you set up a feed on).**
When a Gravity Forms entry matches a feed you created, the plugin posts that entry to `https://itpscrm.com/api/form_webhook.php` with your site key. What is sent is exactly what you mapped — typically name, email address and phone number — together with the consent tick-box result and its wording, and the entry's IP address, source page URL, user agent, form title and entry number. Forms with no ITPS CRM feed are never sent.

Service terms and privacy policy:

* Terms of service: https://itpscrm.com/terms.php
* Privacy policy: https://itpscrm.com/privacy.php

Because the chat script sets a visitor identifier and reports page views, you should mention ITPS CRM in your own site's privacy policy, and — where the GDPR, the ePrivacy Directive or a similar law applies to your visitors — obtain consent before switching the widget on. The `itps_crm_load_widget` filter exists so a consent-management plugin can hold the widget back until the visitor agrees.

== Installation ==

1. Upload the plugin and activate it.
2. **Settings → ITPS CRM**. Enter your CRM address (for example `https://itpscrm.com`) and your site key, which is in the CRM under **Automations**.
3. Press Save. The page tells you what it connected to and what is now switched on.
4. For forms: open a form → **Settings → ITPS CRM** → add a feed and map the fields.

== Frequently Asked Questions ==

= Do I need an account somewhere else for this to work? =

Yes. This plugin is the WordPress end of ITPS CRM, a hosted service at itpscrm.com. Without a CRM address and site key it stays inert — no script is loaded and no request is made. The *External services* section above lists every connection it makes.

= What can the site key do? =

Add leads to your workspace, and read your own field names so the mapping dropdown can be filled in. It cannot read contacts, deals, or anything else, and you can replace it in the CRM at any time.

= Can I stop the chat appearing on one particular page? =

Yes — the `itps_crm_load_widget` filter. Return false for the pages you want it off. It is also the hook to use if a consent-management plugin should decide.

= Our own staff keep appearing in the visitor list. =

Tick *Hide it from logged-in editors and administrators* on the settings page.

= Gravity Forms is not installed. =

The chat and visitor tracking work on their own. The form feed appears when Gravity Forms is.

= What does uninstalling remove? =

The plugin's two options, and nothing else. Leads already sent are your data and live in the CRM; Gravity Forms feeds belong to Gravity Forms.

== Changelog ==

= 1.0.1 =
* The chat widget and visitor tracking are now off until an administrator switches them on, and the setting says what it sends. Terms and privacy links corrected; shorter description.

= 1.0.0 =
* First release: webchat and visitor tracking from a tick-box, Gravity Forms field mapping driven by the workspace's own fields, and SMS consent recorded with the wording, page, address and entry it came from.
