| Duration | ~50 min in the lesson + ~25 min homework |
| Prerequisites | Checkpoint lesson-6.9; a Facebook account with access to Meta Business tools |
| Checkpoint | lesson-7.2 |
What you will have
Meta receives a PageView event on every page and a Lead event on each successful form submission, both sent from the browser through GTM, only after the visitor has consented, and each carrying an event ID.
Video
The video for this lesson is not recorded yet.
Prompts used in this lesson
Part 4 — Demonstration: event IDs in the data layer
Purpose: prepare the site for the Meta Pixel. Each page view and each lead needs a unique event ID in the data layer, so GTM can pass it to Meta and so the server can later send the same ID for deduplication. Context: brightside-site at lesson-6.9. The data layer pushes from lesson 6.4 are already in place (form_start, form_submit, generate_lead, cta_click). The consent banner from 6.5 sets Consent Mode v2 signals. Read docs/measurement-plan.md first. Do this: 1. When the lead form is submitted, generate one UUID in the browser. Include it as event_id in the generate_lead data layer push, and send the same value in the request body to /api/leads (the endpoint may ignore it for now, but must not reject it). 2. On each page load and each client-side navigation, push a page_event_id (a fresh UUID) to the data layer before GTM's page view trigger needs it. 3. Check how the consent banner tells GTM that the visitor changed their choice. If it does not already push a data layer event when consent is updated, add one named consent_update, pushed after the Consent Mode update call. 4. Update docs/measurement-plan.md with the new parameters. Constraints: no personal data in the data layer. Do not add the Meta Pixel code to the site; it will be installed through GTM. Do not change the event names. Done when: the build passes; you have loaded the site in a browser, submitted a test lead and confirmed in the console that window.dataLayer contains generate_lead with an event_id, that the same ID was in the request to /api/leads, and that a consent_update event appears after accepting the banner. Report the evidence.
Do along
Pause the video where told and do each step on your own project.
- After Part 4, pause: from
lesson-6.9, run the prompt from Part 4. Deploy. - In Events Manager create your web dataset and copy the dataset ID, as in Part 2. Decline automatic setup options.
- After Part 6, pause: in GTM create the constant for the dataset ID, the two data layer variables, the base tag and the Lead tag, with consent requirements, triggers and sequencing as shown.
- If your conversion is not a quote request, pick the standard event that fits (for example
ContactorSchedule) and note it indocs/measurement-plan.md. - After Part 7, pause: test in GTM Preview: reject path, accept path, lead.
- Test in Events Manager's Test events tab.
- Publish the container. Add a "Meta Pixel" section to
docs/tracking-qa.mdwith the date and results. Commit and tag.
Check your work
- With consent rejected, open the browser's network tab and filter for
facebook: no requests. Expected: none. - With consent accepted: a request for the pixel library and a
PageView. - Submit a test lead: Events Manager → Test events shows
Leadreceived from the browser, once. - The Lead event in the tool shows an event ID equal to the
event_idin thegenerate_leaddata layer push. - The test lead is in the CRM, as before.
Common problems
- Nothing appears in Test events → an ad blocker or strict browser privacy setting is blocking Meta, or consent was not accepted. Test in a clean profile and accept the banner. This blocking is exactly what the next lesson works around.
- Lead tag fires but GTM shows "fbq is not defined" → the base tag had not run. Check tag sequencing and that the base tag has the
consent_updatetrigger. - PageView appears twice per page → the base tag fired on both triggers. Set "Once per page", or split library loading from the PageView call.
- Event ID is
undefined→ the data layer variable name does not match the key. Ask Claude: "Show me the exact generate_lead push and its keys" and compare with the variable. - Lead appears on clicking the button, not on success → the wrong trigger is attached. It must be
generate_lead, notform_submit. - Pixel fires before consent → the additional consent setting is missing on one of the tags. Check each Meta tag.
Homework
About 25 minutes, on your own, after the lesson. No later lesson depends on it.
- Second device. Repeat the reject, accept and lead test on your phone or in a second browser. Mark the lead as a test in the CRM. Deliverable: three lines in the "Meta Pixel" section of
docs/tracking-qa.md: the device, and what happened at each step, including whether Events Manager listed the events. Done when: all three results are written down, including any that differ from your first test. - What Meta receives, in your words. Write five sentences for a customer who asks what your site tells Facebook: which events, when, what they contain and what they leave out. Deliverable: that paragraph in
docs/tracking-qa.md. Done when: a person outside the course can read it and repeat back what is sent when they submit the form. - Other actions, other events. List the other things a visitor can do on your site, such as pressing a call-to-action button. Beside each, write the standard event from Meta's reference (see Materials) that would describe it, or "none". Decide only: build nothing and leave the published container as it is. Deliverable: a table in
docs/measurement-plan.mdheaded "Meta: possible later events". Done when: every action has an event name or "none" and a one-line reason.
If a task changed files in the project, commit and push without a tag: git add -A, git commit -m "Homework 7.2", git push.
Save your work
git add -A
git commit -m "Lesson 7.2: Meta Pixel via GTM with consent and event IDs"
git tag lesson-7.2
git push
git push --tags