Skip to main content

Ads and pixels

Pinterest Tag

Configure the Pinterest Tag

Copy the numeric tag ID from Pinterest Ads Manager. Remove Pinterest's base code and its <noscript> image. The helper does not emit that image, because it fires without JavaScript and c15t cannot gate it.

npm install @c15t/integrations@alpha
src/consent-scripts.ts
import { pinterestTag } from '@c15t/integrations/pinterest-tag';

export const scripts = [pinterestTag({ tagId: '2613654212508' })];

Register the scripts

Complete your framework quickstart first. Keep its Inth endpoint, policy, styles and consent UI. Remove the vendor's original script, SDK initializer or tag-manager entry, so the vendor loads only through c15t.

The vendor pages put the helper in src/consent-scripts.ts. If your framework quickstart already has a scripts array, such as the one in c15t.config.ts in the Next.js guide, add the helper to that array instead of creating a second file. The scripts export is a configuration, not an initializer. Add it to the c15t provider you already have, at the registration point for your framework below. These are edits to that provider, not a second provider.

Add the configuration to scripts in c15t.config.ts, next to next.config.ts:

import { defineConsentConfig } from 'c15t/next';
import { scripts } from './src/consent-scripts';

export default defineConsentConfig({ scripts });

Keep the rest of your config, such as mode and routePrefix, in the same call. ConsentRoot reads the config in the browser, so the layout keeps passing only state. App Router, Pages Router and static export all read the same file. See Next.js scripts and embeds.

Options

OptionDefaultBehavior
tagIdRequiredTag ID passed to pintrk('load', ...). The helper trims it. Empty or whitespace-only values log an error and the script does not load.
loadOptionsNoneObject passed as the third argument to pintrk('load', ...), such as em or external_id for enhanced match. Pass user data only when your app has the permission it needs.
trackPageVisittrueQueues pintrk('page') after load. Set false to send page visits yourself.
scriptUrlhttps://s.pinimg.com/ct/core.jsLoader URL override. A blank value falls back to the default.

Loading and revocation

pinterestTag uses the marketing category. Before marketing is allowed, c15t defines no pintrk function and loads nothing from Pinterest. When marketing becomes allowed, the helper queues load, pintrk('setconsent', true) and the page visit, then loads core.js.

On revocation the helper keeps the tag and calls pintrk('setconsent', false), which Pinterest documents as stopping events and clearing its first-party storage. If the visitor allows marketing again before the page reloads, the helper calls pintrk('setconsent', true).

Guard your own pintrk calls

The helper sends the page visit. Events your code sends, such as checkout or lead, need their own check. After revocation window.pintrk still exists, so its presence does not mean marketing is allowed. Check the permission first, then that the tag has loaded:

src/track-checkout.ts
export function trackCheckout(marketingAllowed: boolean, orderId: string) {
	if (!marketingAllowed || typeof window.pintrk !== 'function') return;
	window.pintrk('track', 'checkout', {
		currency: 'USD',
		event_id: orderId,
		order_id: orderId,
		value: 99.99,
		line_items: [{ product_id: '1414', product_quantity: 1 }],
	});
}

Pass the current marketing permission from your framework, for example useConsent('marketing') in React. Put product details in line_items, and set event_id to deduplicate against the Conversions API. Pinterest reports conversions only for its 20 event types. It keeps other event names for audience targeting.

@c15t/integrations/pinterest-tag also exports pinterestTagEvent, a typed wrapper around pintrk('track', ...). It does nothing until pintrk exists and does not check permission, so apply the same guard before calling it. Its optional third argument receives Pinterest's (didInit, error) result.

Verify the Pinterest Tag

After you allow marketing, core.js loads from s.pinimg.com and Pinterest Tag Helper shows the page visit. Trigger one guarded event and check that Tag Helper records it. Then revoke marketing. Until the page reloads, calling trackCheckout sends nothing.

Test in a private window with an opt-in policy. Open DevTools Network, disable the cache and filter by the vendor's domain:

  1. Load the page. No request goes to the vendor before you choose.
  2. Click Reject, then reload. There is still no vendor request.
  3. Open Privacy settings and allow the helper's category. The vendor script loads without a page reload.
  4. Turn the category off again and save. c15t reloads the page, and the new page makes no vendor request.

c15t reloads on revocation because removing a script element does not stop code that already ran. The vendor's listeners, timers and queued events stay alive until the page unloads. If you set reloadOnConsentRevoked: false, stop the vendor yourself. Register a callback-only script whose onConsentChange calls the vendor's opt-out API, as shown in custom integrations, and check the permission before each of your own event calls. The reload does not delete cookies the vendor already set; see clear on revocation for your framework.

The helper sets vendor to its script ID, so once you declare that vendor a visitor can turn it off inside an allowed category. See vendor consent for your framework. The consent verification guide covers navigation, expiry and hosting checks.