How to track custom events with Claude or an AI agent
Use a prompt to add one completed website action to your Crisper setup. Pick the standard event name, send email and phone, count it once and check delivery.
Shahzada Ali Hassan, founder of Crisperchecked against 10 sources
The short answer
Paste the prompt below into your coding agent, then describe the action you want counted. The agent picks the standard event name, pushes it to the data layer as <name>_crisper with the customer's email and phone, and checks that a refresh does not count it twice. Platform delivery still needs its own check.
- Each event is one data layer push named
<name>_crisper, such asgenerate_lead_crisperfor a Lead orpurchase_crisperfor a Purchase. user_datais a flat object.emailandphoneare required; every other field is optional.- GA4 purchasedevelopers.google.com requires
transaction_idanditems; includecurrencywhen sendingvalue. - Page views and phone, email and WhatsApp link clicks are already tracked. Don't push them.
- Prompt checked against the Crisper web and server tag containers and Google, Meta and Claude documentation on 29 October 2026.
FREE CALL
30 MINMeta stopped counting your leads? Get them counted again.
- Pick a time
Check your Meta account with Hassan- See what to do next
On a free 30-minute call, Hassan checks your Meta account with you and shows you what to do next.
Not ready to talk? Run a free check
For example: "Track a Lead when someone lands on /thank-you after the opt-in form." For a purchase, name the completed order or payment you want to count.
01What prompt should I paste into Claude or my AI agent?
Copy this prompt into the project where your agent can edit the site, then describe your event. It contains the naming rules, the data structure and the acceptance checks, so you do not need to write the tracking code yourself.
Describe the action in your own words. The agent matches it to Meta's and Google's standard event lists and tells you the name it chose before writing code.
Prompt for your website coding agent
Read the full prompt
Implement one website event in this project using its existing Crisper installation. Every event is a window.dataLayer.push. Do not add Google Tag Manager, gtag.js, a Meta Pixel or any other tracking script.
1. Inspect before editing
Find the requested action's success handler, the existing tracking and any order or product data. Check whether the action is already tracked, and keep the change scoped to this event.
Crisper already tracks some actions. Do not push an event for them, or they are counted twice:
- page views on every page
- clicks on tel:, mailto: and wa.me links
- embedded GoHighLevel, Typeform, Calendly and ClickFunnels forms and bookings, in their usual setups: Typeform when it sends people to a thank-you page on this site, Calendly when the booking returns to this site with its confirmation
Report any of these instead of adding an event. If you are not sure one is tracked, ask me to submit one test and check that it shows in Crisper Logs before you skip it: in Logs, Typeform shows as Submit Application and Calendly bookings as a schedule event.
Ask only for missing answers:
- What action should count, and where does it happen?
- Which customer and order fields are you permitted to share?
2. Choose the event name
I may describe the event loosely, for example "LEAD", "track bookings" or "fire purchase on the thank-you page". Match it to a standard event, whatever the spelling or capitals:
- Fetch Meta's standard events: https://developers.facebook.com/documentation/meta-pixel/reference#standard-events
- Fetch Google Analytics 4 recommended events: https://developers.google.com/analytics/devguides/collection/ga4/reference/events
Then name the event in lowercase snake_case and add _crisper. Crisper sends these names to Meta as standard events:
generate_lead_crisper (Lead), purchase_crisper (Purchase), contact_crisper (Contact), schedule_crisper (Schedule), sign_up_crisper (CompleteRegistration), begin_checkout_crisper (InitiateCheckout), view_item_crisper (ViewContent), add_to_cart_crisper (AddToCart), add_payment_info_crisper (AddPaymentInfo), add_to_wishlist_crisper (AddToWishlist), submit_application_crisper (SubmitApplication), start_trial_crisper (StartTrial), subscribe_crisper (Subscribe), find_location_crisper (FindLocation), customize_product_crisper (CustomizeProduct), donate_crisper (Donate).
Never use search_crisper, view_item_list_crisper, view_collection_crisper, add_shipping_info_crisper, add_contact_info_crisper or add_address_info_crisper: Crisper does not forward them. Never push page_view_crisper either: page views are already sent on every page, so it would count twice.
If no standard event fits, say so and ask before using a custom name. Tell me the name you chose and why in one line before implementing.
3. Emit this contract
Clear the previous event's values with undefined, not null, then push the event. Google Tag Manager reads every field under a null object as false and sends it to Meta and GA4:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: undefined, user_data: undefined });
window.dataLayer.push({
event: "<confirmed_name>_crisper",
user_data: {
email: "<email>",
phone: "<phone>"
}
});
user_data is a flat object. Required: email and phone. Optional: first_name, last_name, street, city, region, zip, country and customer_id. Email trimmed and lowercase. Phone in international format, + and digits only. Leave out any field you don't have; never send empty strings, null or placeholders. Keep free-text answers and health or other sensitive details out of event data. Preserve existing consent behavior.
If the action happens on a later page than the form, save the contact details when the form is accepted (cookie or localStorage, about 7 days), read them back for later events, and delete them after the final purchase.
Fire only after the action succeeded: the server accepted the form, the payment is confirmed, the booking is made. Never on a button click alone or a plain page load. Read form values before the form resets. If the page navigates right after the push, use eventCallback with a one-second fallback before navigating.
Fire once per real action. Once an event is sent, save a unique key: the lead or submission ID for a lead, the transaction_id for an order. Never use the email as the key: a second real enquiry from the same person must still fire. Skip the event if its key is already saved. A new lead or a new order still fires; a refresh, Back or reopened page does not.
4. Add ecommerce for money events
For purchase, begin_checkout, add_to_cart, add_payment_info, view_item or a subscription, add an ecommerce object beside user_data, filled from the real order or cart, never hard-coded:
- view_item: the viewed product.
- add_to_cart: only the items and quantities added in that action.
- begin_checkout: the cart entering checkout.
- add_payment_info: the completed payment step.
- purchase: the confirmed order and its final items.
Purchase example with synthetic values; replace every value in the implementation:
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({ ecommerce: undefined, user_data: undefined });
window.dataLayer.push({
event: "purchase_crisper",
user_data: {
email: "customer@example.com",
phone: "+15555550123",
first_name: "Alex",
last_name: "Example"
},
ecommerce: {
transaction_id: "EXAMPLE_ORDER_1001",
currency: "USD",
value: 49.98,
tax: 3.50,
shipping: 5.00,
items: [
{
item_id: "EXAMPLE_SKU_1",
item_name: "Example product",
price: 24.99,
quantity: 2
}
]
}
});
items has one entry per product with item_id and/or item_name, the numeric discounted unit price and quantity. Take product details from the order; if the order lacks them, from the page. currency is the order's three-letter code and is required with value; without it the purchase is recorded in USD. value is the sum of price times quantity, excluding tax and shipping; send known tax and shipping separately. Convert minor-unit amounts and avoid subtracting a discount twice. transaction_id is the real, stable order ID. Report missing required data instead of inventing values.
5. Verify and report
Use local fixtures or test-mode checkout, with no real enquiry or charge. Test success, failure, a repeated success or reload, a genuinely new action (including a second enquiry with the same email), and a lead after a purchase with no stale order fields. Check that the event appears in window.dataLayer once with the right name, the contact fields and, for money events, the order values.
Keep GTM containers, integrations, campaigns and payment settings unchanged. Report a missing installation or forwarding step to the site owner or Crisper support instead of adding another sender.
Finish with the files changed, each event name, the page and moment it fires, a synthetic example payload and the test results. Keep website implementation, platform delivery and ad attribution as separate results.02What should the agent ask me?
The agent should ask about the action and the permitted fields when the site code does not settle them. It works out the event name itself. Use the illustrative answers below to describe your own setup.
What action should count, and where?
- Example answer
- "A successful submission of the contact form on /contact."
Which available details are permitted to share?
- Example answer
- "Use the form's email and phone fields. For purchases, include the confirmed order and its product data."
03What does my AI agent need access to?
It needs your website project, permission to edit it and an installed Crisper tracking setup. Claude Code reads your codebase, edits files and runs commandscode.claude.com from the terminal, an IDE, a desktop app or the browser; an AI website builder can use this prompt where it has equivalent access. A chat-only assistant can suggest code for someone to install.
For a third-party form or checkout, the agent needs a documented completion signal rather than a guess about which button counts. The form and booking guide covers those signals. Connecting an agent to your Crisper account is separate; use the MCP guide for that setup.
04Which event name should the agent use?
Use the standard name for the action, in lowercase snake_case, with _crisper on the end. Crisper's tag setup forwards _crisper events to Google Analytics 4 without the suffix, except the names listed below, and its Meta connection turns the standard names into Meta standard events.
The prompt has the agent fetch Meta's standard eventsdevelopers.facebook.com and GA4's recommended eventsdevelopers.google.com and match your request to them. Spelling and capitals don't matter in your request. "LEAD", "new lead" and "form lead" all become generate_lead_crisper.
Lead form accepted
- Data layer event
generate_lead_crisper- Arrives in Meta as
- Lead
Order paid
- Data layer event
purchase_crisper- Arrives in Meta as
- Purchase
Contact button clicked
- Data layer event
contact_crisper- Arrives in Meta as
- Contact
Booking made
- Data layer event
schedule_crisper- Arrives in Meta as
- Schedule
Account created
- Data layer event
sign_up_crisper- Arrives in Meta as
- CompleteRegistration
Checkout started
- Data layer event
begin_checkout_crisper- Arrives in Meta as
- InitiateCheckout
Product viewed
- Data layer event
view_item_crisper- Arrives in Meta as
- ViewContent
Added to cart
- Data layer event
add_to_cart_crisper- Arrives in Meta as
- AddToCart
Payment details added
- Data layer event
add_payment_info_crisper- Arrives in Meta as
- AddPaymentInfo
Application submitted
- Data layer event
submit_application_crisper- Arrives in Meta as
- SubmitApplication
Trial started
- Data layer event
start_trial_crisper- Arrives in Meta as
- StartTrial
Subscription started
- Data layer event
subscribe_crisper- Arrives in Meta as
- Subscribe
_crisper names checked against the live web container on 6 November 2026. add_to_wishlist, find_location, customize_product and donate map the same way. Any other name reaches Meta as a custom event.Six names are not forwarded at all: search_crisper, view_item_list_crisper, view_collection_crisper, add_shipping_info_crisper, add_contact_info_crisper and add_address_info_crisper. Never push page_view_crisper either: page views are already sent on every page, so it would count twice. If no standard event fits, the prompt has the agent ask you before inventing a name. Custom names follow GA4's naming rulessupport.google.com: start with a letter, use only letters, numbers and underscores, and remember that my_event and My_Event are two events.
05What does the event structure mean?
Each event is one message on the page's data layer, the list of messages your page hands to Google Tag Manager. Google's data layer documentationdevelopers.google.com explains that a message with an event key fires any tag whose trigger conditions it meets, and that you should never overwrite the window.dataLayer variable.
event
- Purpose
- The standard name plus
_crisper, such asgenerate_lead_crisper.
user_data
- Purpose
- A flat object of customer details.
emailandphoneare required.first_name,last_name,street,city,region,zip,countryandcustomer_idare optional.
ecommerce
- Purpose
- Order or cart data for money events, beside
user_data. Omit it from an ordinary lead.
Email goes in trimmed and lowercase, and phone in international format with only + and digits. A missing field is left out rather than sent empty. Before each event, the agent pushes { ecommerce: undefined, user_data: undefined } so one event never inherits the previous event's order or customer.
When the event happens on a later page than the form, such as a thank-you page after an opt-in, the agent saves the contact details when the form is accepted and reads them back there. Keep names, treatments and other sensitive details out of event names and fields.
06Can the agent also add ecommerce objects?
Yes. The prompt includes a full purchase example and tells the agent to fill every value from the real product, cart or order. Google's ecommerce guidedevelopers.google.com describes when these shopping events apply.
Product viewed
- Event and items
view_item_crisper: the viewed product.
Cart addition succeeds
- Event and items
add_to_cart_crisper: only items and quantities added in that action.
Checkout begins
- Event and items
begin_checkout_crisper: the cart entering checkout.
Order completes
- Event and items
purchase_crisper: final order items and the stabletransaction_id.
items
- Value to use
- An array of products. Each has an
item_idand/oritem_name, numeric unitpriceandquantity, taken from the order, or from the page when the order lacks them.
currency and value
- Value to use
- The order's three-letter currency and the sum of discounted item price times quantity. Without
currency, Crisper records the value in USD.
transaction_id
- Value to use
- The real, stable order identifier for a purchase.
tax and shipping
- Value to use
- Separate numeric amounts when known. Exclude them from item value.
In the illustrative prompt example, two units at 24.99 give a value of 49.98. Shipping of 5.00 and tax of 3.50 stay separate. Google's purchase referencedevelopers.google.com marks transaction_id and items required, and says that when you set value, currency is required for revenue metrics to be computed accurately.
07How do I check that the event fires correctly?
Ask for the test results, not just a list of edited files. A successful lead or purchase should count once; a failed attempt should not count as that conversion.
- Complete the action with local fixtures or test-mode data. Done when: the event appears once in
window.dataLayerwith the right_crispername,email,phoneand any order values. - Test failure, repeat the success callback and reload the confirmation page. Done when: failure produces no conversion and the same lead or order is not counted again.
- Complete a genuinely new action, including a second enquiry with the same email. Done when: a new lead or a new order still counts, and a later lead does not inherit the previous order.
- Check the outgoing request and platform receipt. Done when: the received event matches your test action, or your report names the exact delivery step still unverified.
The browser payload, platform delivery and ad attribution are separate results. The tracking verification guide explains what to check at each stage.
08Which custom event mistakes should I avoid?
Avoid counting attempted submissions as leads, counting one action twice and sending incomplete purchase values. The table separates counting mistakes from platform rules.
Firing the lead on the Submit click instead of the accepted submission
- What it costs
- Failed and repeated submissions are counted as leads, and the platform receives an event for an enquiry that never arrived.
- Fix
- Fire after the success callback and capture the values before the form resets, as the prompt instructs.
Pushing an event for an action Crisper already tracks
- What it costs
- Page views,
tel:,mailto:andwa.meclicks, and embedded GoHighLevel, Typeform, Calendly and ClickFunnels forms in their usual setups are counted twice. - Fix
- Let the existing tracking count them. The prompt has the agent check first; when unsure, submit one test and look for it in Crisper Logs (Typeform shows as Submit Application, Calendly as a
scheduleevent).
Firing again on refresh or a second visit
- What it costs
- One lead or order is counted several times.
- Fix
- Save the lead or submission ID, or the
transaction_id, once sent and skip that key next time. Not the email: a second enquiry from the same person is a new lead.
Naming the event after the treatment or the condition
- What it costs
- Meta prohibits event names that imply sensitive health informationfacebook.com. It may block custom events containing potentially prohibited informationfacebook.com.
- Fix
- Use the standard name for the action, such as
generate_lead_crisper.
Sending value without currency, or with tax and shipping folded in
- What it costs
- Google's purchase referencedevelopers.google.com requires currency for accurate revenue metrics when value is set, and excludes tax and shipping from value.
- Fix
- Send the three-letter currency with every value, and send tax and shipping as their own fields.
This prompt is not a complete setup for a third-party booking embed: use its documented completion signal from the booking guide. A new name does not establish that a restricted Lead is usable; Meta requires confirmation of custom events on restricted sources, or they may be unavailablefacebook.com.
09Does the agent need access to GTM or Events Manager?
No. The prompt keeps GTM containers, integrations, campaigns and payment settings unchanged, and asks the agent to report any missing forwarding step. Someone with platform access checks delivery after the website change has been reviewed.
10What if the event or its details still do not appear?
Locate the first missing step: the success signal, data-layer event, outgoing request or platform receipt. Crisper's tag for _crisper events reads user_data and ecommerce from the data layer, so a missing field usually means the push left it out or used a nested or misspelled key. Give Crisper support the payload and the missing fields so the delivery can be checked.
For a custom Meta event, also check Meta's review requirementsfacebook.com: on a data source with data restrictions, custom events are blocked until you review and confirm them, or may not be available. The custom-event restriction guide covers that case.
For an installed Crisper site, use the prompt and review the website change through your normal release process. Keep its test results and confirm destination receipt before relying on the event for reporting. The prompt adds a website action; it does not install Crisper or decide whether Meta can use that event.
11What changed in this guide
- 15 November 2026: The page now books a free call; our team does the setup.
- 6 November 2026: Event names now end in
_crisper; names in the older format still work. Never-forwarded names now list six, and page views are covered separately. Typeform and Calendly are counted only in their usual setups; check Logs when unsure. The prompt now deduplicates leads by lead or submission ID, never by email. - 29 October 2026: Events now use the Crisper event-name suffix format instead of
gtm_custom_eventwithdatalayer_event_name, so customer details and order data reach Meta and Google. Added the event name table, required and optionaluser_datafields, the actions Crisper already tracks, and once-per-action checks. - 25 October 2026: Added Google's naming and purchase parameter rules and Meta's event-name restrictions. Added short key facts, mistakes and completion checks; kept the copyable prompt unchanged.
Sources
10 sources
- 1GA4 purchasedevelopers.google.com↩
- 2Claude Code reads your codebase, edits files and runs commandscode.claude.com↩
- 3Meta's standard eventsdevelopers.facebook.com↩
- 4GA4's recommended eventsdevelopers.google.com↩
- 5GA4's naming rulessupport.google.com↩
- 6data layer documentationdevelopers.google.com↩
- 7ecommerce guidedevelopers.google.com↩
- 8Meta prohibits event names that imply sensitive health informationfacebook.com↩
- 9It may block custom events containing potentially prohibited informationfacebook.com↩
- 10Meta requires confirmation of custom events on restricted sources, or they may be unavailablefacebook.com↩

