Skip to content

Ad Pixels ​

Meta, TikTok, LinkedIn, Google Ads, Microsoft Advertising, Pinterest, Snapchat and X pixels on the site's pages, with the shop's sales as conversions.

kitloom/ad-pixels · admins: kitloom/ad-pixels-filament, kitloom/ad-pixels-nova

Video lessons ​

Recorded in the Filament admin; the Nova admin works the same way.

Ad Pixels Settings

The ad networks' pixels on the site's pages: Meta (Facebook and Instagram), TikTok, the LinkedIn Insight Tag, the Google Ads tag, Microsoft Advertising (UET), Pinterest, Snapchat and X (Twitter). Ads can then be measured, and site visitors can be found again in the networks' audiences. It does what the networks' own WordPress plugins, PixelYourSite or Site Kit did on the WordPress site, and their IDs can be imported. The admin page is the Ad Pixels section (kitloom/ad-pixels-filament or kitloom/ad-pixels-nova).

Setting it up ​

Open Ad Pixels → Settings and fill in the IDs of the networks you advertise on. An empty ID means that pixel is off. An ID that does not look like one is refused when you save, so a typo never reaches the site.

PixelWhat to enterWhere to find it
MetaThe pixel (dataset) ID, digitsMeta Events Manager → Data sources
TikTokThe pixel code, C…TikTok Ads Manager → Assets → Events → Web events
LinkedInThe partner ID, digitsCampaign Manager → Analyze → Insight Tag
Google AdsThe conversion ID, AW- and digitsGoogle Ads → Goals → Conversions → a conversion action → Tag setup: the AW-… part of send_to, before the slash
Google Ads purchase conversion label (optional)The label of your purchase conversion, such as AbC-D_efG-h12The same Tag setup of your purchase action: the part of send_to after the slash
Microsoft AdvertisingThe UET tag ID, digitsMicrosoft Advertising → Conversions → UET tag
PinterestThe tag ID, digitsPinterest Ads Manager → Conversions
SnapchatThe Snap pixel ID, such as 1a2b3c4d-1234-5678-9abc-1a2b3c4d5e6fSnapchat Ads Manager → Events Manager → your Snap pixel
XThe pixel ID, a few letters and digits such as o1a2bX Ads → Tools → Events Manager → your X pixel
X purchase event ID (optional)The ID of a Purchase event, tw-…-…X Events Manager: add a Purchase event to your pixel and copy its ID

Every page of the theme gets:

  • each pixel's base code with its page view, where the theme put @siteHead;
  • for visitors without JavaScript, Meta's, LinkedIn's, Microsoft's and Pinterest's image right after <body> (@siteBodyOpen). Google Ads, TikTok, Snapchat and X have no such image.

In an Inertia theme, the next page opens without a reload:

  • Meta, TikTok, Google Ads, Pinterest and Snapchat are sent a page view for it by the module.
  • Microsoft's UET tag notices the new address by itself (its automatic tracking of single-page sites is on).
  • LinkedIn's and X's tags have no page-view call to repeat, so they count the first page.

Shop sales ​

With the shop module, the pixels also receive the shop's sales as their networks' standard events:

ShopMetaTikTokGoogle AdsMicrosoftPinterestSnapchatX
A product page is openedViewContentViewContentview_itemproduct page (ecomm_pagetype: product)pagevisitVIEW_CONTENT—
A product goes into the cartAddToCartAddToCartadd_to_cartadd_to_cartaddtocartADD_CART—
The checkout form is openedInitiateCheckoutInitiateCheckout—begin_checkoutinitiatecheckoutSTART_CHECKOUT—
The "order received" page is shownPurchaseCompletePaymentpurchase, and the conversion if its label is filled inpurchasecheckoutPURCHASEyour purchase event, if its ID is filled in

Each event carries the products, the value and the currency, in the names each network uses. A product is named as the Ads module's product feed names it — its SKU, or its number where it has none; a variation by its own — so a catalogue filled from that feed (Meta, Google Merchant Center, Pinterest, Microsoft) recognises what was viewed and bought, which dynamic and catalogue ads depend on:

  • Google Ads: the products as items with google_business_vertical: retail, which dynamic remarketing reads; every event is sent to your AW-… account only. With the purchase conversion label, a purchase is also counted as that conversion, with the value, the currency and the order number (transaction_id), so a reload does not count it twice. Google lists no checkout event for remarketing, so none is sent.
  • Microsoft Advertising: ecomm_prodid and ecomm_pagetype (dynamic remarketing), ecomm_totalvalue, currency and items; a purchase also revenue_value and transaction_id. To count purchases as conversions, make a goal in Microsoft Advertising for the event action purchase, with revenue from the tag.
  • Pinterest: value, currency, order_quantity and the products as line_items; a checkout also order_id.
  • Snapchat: price, currency, item_ids and number_items; a purchase also transaction_id.
  • X: conversions on X are events you make in X Events Manager, each with its own ID; this module sends the purchase to the one you name, with value, currency and the products as contents.

A purchase also carries the event ID purchase-{order number} (Meta, TikTok, Pinterest; X's conversion_id), which is how Meta matches it to the same purchase sent from the server (below). Each order is sent once per browser. A failed or cancelled order is not sent.

Meta Conversions API: purchases sent from the server ​

A pixel in the browser misses the purchases of visitors with an ad blocker, and part of those on Safari and iOS. With the shop module and an access token, every purchase is also sent to Meta from the server, so your ads are measured and taught by all of them.

  1. In Meta Events Manager, open your pixel (dataset) → Settings → Conversions API → Generate access token, and copy it.
  2. Paste it into Meta Conversions API access token on Ad Pixels → Settings and save. The token is kept encrypted and is never shown again; an empty field keeps the saved one.
  3. To try it first: Events Manager → Test events shows a code such as TEST12345. Put it into Meta test event code, place an order, and watch it appear on that tab. Events with a code are not counted, so empty the field when you are done.

What happens then:

  • When. Once an order is paid (Processing or Completed) or put On hold for a payment made by hand — the orders the pixel on the "order received" page counts. An order still waiting for its payment is sent when the payment arrives; a failed or cancelled one never is. Each order is sent once.
  • No double counting. The server's purchase carries the same event ID as the browser's, purchase-{order number}, and Meta keeps one of the two.
  • What is sent. The products, the value and the currency as the pixel sends them; the order's email, phone, name, city, region, postcode and country, each hashed (SHA-256) as Meta requires; the IP address and browser the order was placed from; the pixel's own browser and click IDs (the _fbp and _fbc cookies) and the checkout page's address.
  • Who is not sent. The same visitors the pixel leaves alone: one who did not agree to marketing in the Cookie Consent banner (no answer counts as no), and signed-in users unless Track signed-in users is on. For them the order keeps nothing for Meta.
  • From the queue. The customer's page never waits for Meta. A site without a queue worker sends it at the end of the checkout request. A failed send is tried again for a few hours; what Meta answered last is shown under the token field.
  • Privacy requests. With the Privacy module, Export Personal Data lists what an order kept for Meta under "Ad tracking of orders", and Erase Personal Data removes it.

Only purchases are sent from the server. Product views, carts and checkouts started still come from the browser's pixel.

The Graph API version is pinned in config/kitloom-ad-pixels.php (conversions.graph_version), where conversions.register also turns the whole thing off.

LinkedIn conversions are set up in Campaign Manager, by URL (the "order received" page) or by event.

Ad pixels are marketing. With the Cookie Consent module installed, each pixel waits until the visitor agrees to marketing. The images for visitors without JavaScript are left out: without JavaScript there is nobody to ask. Without a consent module, the pixels load at once.

The Google Ads tag is the exception when the banner's Google Consent Mode is on: then it loads at once, after the consent defaults (ads denied), and Google keeps to the visitor's answer — no ad cookies until they agree to marketing. If Google Analytics is on the page too (the Analytics module), both share one Google tag.

Who is tracked ​

Signed-in users (editors, administrators, customers with an account) are not tracked by default, so the site's own people do not end up in the ad audiences. Track signed-in users turns that off. Pages for guests are cached as before: a signed-in user's page is always drawn anew, so leaving the pixels out of it affects nobody else.

Coming from WordPress ​

If the WordPress site had one of these plugins, the settings page shows an Import button. The console command does the same:

bash
php artisan ad-pixels:import
php artisan ad-pixels:import --from=meta --from=tiktok --from=sitekit
PluginWhat is taken
Meta pixel for WordPressThe pixel of its current connection, otherwise of its older settings
TikTokThe pixel code
LinkedIn Insight TagThe partner ID, if the tag was on. A pasted snippet works too.
PixelYourSiteThe first Meta pixel, if its Meta pixel was on (from its own pys_options table, or from the options)
Site Kit by GoogleThe Google Ads conversion ID of its Ads module (the one Google's partner setup made first, then the one typed in)

Only the IDs are taken. Not carried over:

  • Microsoft, Pinterest, Snapchat and X IDs, and the Google Ads purchase conversion label: their WordPress plugins are not read yet, so type them in once on the settings page.
  • Server-side tokens (Meta's Conversions API, TikTok's Events API, the other networks' conversion APIs). They stay where they are: this module sends nothing from the server.
  • Advanced matching (visitors' emails sent to the networks).
  • Events beyond the page view and the shop's sales, such as leads.

The plugins' own settings are not touched.

For developers ​

  • Settings: ad_pixels_*, declared by AdPixelsOptions and written through SettingWriter. An ID that does not look like one is never put into a page.
  • How the pixels reach the page:
    • AdPixelsScripts is the PageScriptsProvider.
    • Each network is a Pixels\Pixel, with its head code and its image.
    • Both go through kitloom/site's ScriptConsent::gate() as marketing; the Google Ads tag says it reads Google Consent Mode (Pixel::googleConsentMode()).
  • CSP: a nonce set with Vite::useCspNonce() goes on the scripts.
  • Config: php artisan vendor:publish --tag=kitloom-ad-pixels-config publishes the admin sections switch.
  • Tests, from the application that installs the package: php vendor/bin/phpunit --testsuite AdPixels.

kitloom — sites on Laravel, built for you and run with AI.
Contact · Services · License · Refunds · Privacy · Community · YouTube · [email protected]