Send the classification to your CRM
ClickPatrol classifies each ad visit as legitimate or suspicious. You can store that result on the lead itself, in HubSpot, in Salesforce, or in any CRM that accepts form fields. Sales then sees which leads came from a suspicious visit. You can keep those out of follow-up, reports, and conversion uploads.
The setup uses a hidden field in your form. Before the form is sent, a small Google Tag Manager tag fills that field with the classification.
Source of the classification#
After the ClickPatrol tag classifies an ad visit, it writes the result to a first-party cookie called cp_class on your domain. Each page of that visit can read it.
- When a value starts with
1.L., it means legitimate. - A value that starts with
1.S.means suspicious. - No cookie means the visit was not classified. Organic, direct, and email visitors land here, because ClickPatrol only classifies ad traffic. So does a visitor whose last ad click is more than 24 hours old.
The ClickPatrol events in the dataLayer carry the same result in the traffic field: safe or fake. The cookie is the easier option for forms, because it is already there when the visitor reaches the form, also on a later page.
Before you begin#
- The official ClickPatrol tag runs on All Pages in Google Tag Manager. If it does not, follow the Google Tag Manager article first. The ClickPatrol WordPress plugin does not write the
cp_classcookie. - The ClickPatrol template in your container is up to date. Older versions do not write
cp_class. If GTM shows an update for the template under Templates, apply that update. - Your form is part of the page itself. A GTM tag cannot reach a field inside an iframe. Some embedded forms, including some HubSpot embeds, render inside one. When yours does, check your form tool for an option to render the form as plain HTML on your page.
Step 1: Create your field in the CRM#
HubSpot#
- As a single-line text field, create a contact property, for example ClickPatrol classification. Note its internal name, for example
clickpatrol_classification. - Put that property on your form and make it a hidden field.
Salesforce Web-to-Lead#
- Create a custom text field, for example ClickPatrol classification, on the Lead object.
- Include that field when you generate or update your Web-to-Lead form. In the generated HTML, a custom field uses its field ID as the input name, a value that starts with
00N. - Change that input to
type="hidden"on your page.
Other form tools work the same way. Use a hidden field mapped to a text field in the CRM. Write down the exact name attribute the field gets in the page HTML, because you need it in step 2.
Step 2: Add your tag in Google Tag Manager#
- Create a new Custom HTML tag named ClickPatrol - fill CRM field.
- Paste the script below, replacing
clickpatrol_classificationwith the name from step 1. - Add two triggers. One is All Pages (DOM Ready). The other is a Custom Event trigger with event name
ClickPatrol_.*and regex matching on. - Save the tag.
<script>
(function () {
var FIELD = 'clickpatrol_classification';
function classification() {
var match = document.cookie.match(/(?:^|;\s*)cp_class=([^;]+)/);
var raw = match ? decodeURIComponent(match[1]) : '';
if (raw.indexOf('1.L.') === 0) return 'legitimate';
if (raw.indexOf('1.S.') === 0) return 'suspicious';
return 'not classified';
}
function fill() {
var value = classification();
var inputs = document.querySelectorAll('input[name="' + FIELD + '"]');
for (var i = 0; i < inputs.length; i++) {
if (inputs[i].value === value) continue;
inputs[i].value = value;
inputs[i].dispatchEvent(new Event('input', { bubbles: true }));
inputs[i].dispatchEvent(new Event('change', { bubbles: true }));
}
}
fill();
if (!window._cpCrmFieldListener) {
window._cpCrmFieldListener = true;
document.addEventListener('submit', fill, true);
}
})();
</script>
When the page loads, the script fills the field. It fills the field again when the classification arrives, and one last time right before the form is submitted. That last step covers forms that load late. The input and change events let form tools that keep their own copy of the field values pick up the new value.
Step 3: Test and then publish#
- In GTM, click Preview. Open the page with your form and add
?source=fto the URL. This forces a test classification. - Submit a test lead.
- Open the record in your CRM. The field should read
legitimateorsuspicious, matching the ClickPatrol event that fired in Tag Assistant. - Without the parameter, submit a second lead in a private window. That record should read
not classified. - Publish the container.
How to use the field#
- Review before sales follow-up. Route suspicious leads to a review list instead of straight to a sales rep. Check them before you delete anything.
- Clean conversion uploads. If you upload offline conversions to Google Ads or another platform from your CRM, leave leads marked suspicious out, so the bidding never learns from them.
- Report per campaign. Combine the field with your UTM or campaign fields to see which campaigns bring the most suspicious leads.
Read not classified as "no verdict". Do not read it as good or bad. Those leads came from organic or direct visits, or from an ad click more than 24 hours before the form.
Limits worth knowing#
- 24-hour window. The classification is kept for 24 hours. Without a new ad click, a lead that converts later arrives as
not classified. - Same browser. The cookie lives in one browser. A visitor who clicks on mobile and fills in the form on desktop arrives as
not classified. - Consent. Visitors who decline are not classified if your consent banner blocks the ClickPatrol tag until consent.
- Legitimate is not qualified. The field tells you a real visitor filled in the form. Whether the lead fits your business is still left to your own qualification.
The classification becomes part of a lead record, and that record also holds personal data. Make sure your privacy notice covers it. See Do we need to put ClickPatrol in our Privacy Policy?
Related articles#
- Count conversions on legitimate visits only: the same cookie, as a condition on your conversion tags.
- Combining ClickPatrol with HubSpot: merging the HubSpot and ClickPatrol tracking templates in Google Ads.
Was this article helpful?
Let us know so we can improve our documentation
Need Help?
If something isn't working or you have questions, our support team is here to help you.
Contact Support