# TikTok Ads Destination Config Reference

<p><a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/tiktok-ads/setup/" >TikTok Ads</a> is an advertising destination. RudderStack sends conversion events to TikTok&rsquo;s Events API from its servers, or loads the TikTok pixel in the browser in device mode.</p>
<p>In a TikTok Ads destination spec:</p>
<ul>
<li><code>type: tiktok_ads</code></li>
<li><code>definition_version: 1</code></li>
</ul>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="sample-configuration">Sample configuration</h2><div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">version: rudder/v1
kind: destination
metadata:
  name: tiktok-ads-prod
spec:
  id: tiktok-ads-prod
  display_name: TikTok Ads Production
  type: tiktok_ads
  definition_version: 1
  enabled: true
  config:
    pixel_code: &#34;{{ .TIKTOK_PIXEL_CODE }}&#34;
    access_token: &#34;{{ .TIKTOK_ACCESS_TOKEN }}&#34;
    version: v2
    hash_user_properties: true

    events_to_standard:
      - from: Order Completed
        to: CompletePayment
      - from: Product Added
        to: AddToCart
    send_custom_events: false

    event_filtering:
      whitelist:
        - Order Completed
        - Product Added

    connection_mode:
      web: device
      cloud: cloud
    consent_management:
      web:
        - provider: oneTrust
          consents:
            - marketing</code></pre></div>
</div>
<p>The above example loads the TikTok pixel on web sources in <code>device</code> mode and sends server-side events in <code>cloud</code> mode. <code>event_filtering</code> affects only the device-mode web traffic — see <a href="#event-filtering" >Event filtering</a>.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="config-keys">Config keys</h2><p><code>config</code> accepts only the keys listed below. The <a href="https://www.rudderstack.com/docs/dev-tools/rudder-cli/destination-types/#config-key-rules" >shared config key rules</a> cover unknown keys, defaults, and immutability.</p>

<html lang="en">
<blockquote class="info">
  <div class="tip-quote">
    
    <div class="tip-text">In <code>cloud</code> mode TikTok Ads accepts only <code>track</code> events. In <code>device</code> mode, web sources also send <code>identify</code> and <code>page</code>.</div>
  </div>
</blockquote>

</html>
<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="connection">Connection</h3><div class="rs-ckeys">
<div class="rs-ckey" id="pixel_code">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">pixel_code</p>RequiredSecret</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Code of the TikTok pixel that receives the events. Used in both modes.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>At most 100 characters, and must not contain line breaks.</li>
<li>A <code>{{ path || fallback }}</code> template is accepted in place of a literal.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/tiktok-ads/setup/#how-do-i-create-a-pixel-in-tiktok-ads" >How do I create a pixel in TikTok Ads?</a>.
</div>

</div>

<div class="rs-ckey" id="access_token">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">access_token</p>Secret</div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p>
<p class="rs-ckey__field">
  Description:
  TikTok long-term access token for the Events API. Cloud mode needs it; device mode doesn&rsquo;t.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Rudder CLI doesn&rsquo;t require this key, even when a source connects in <code>cloud</code> mode. Without it, cloud-mode delivery fails at TikTok.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  Supply it as a <code>{{ .VAR }}</code> reference rather than a literal — see <a href="#secrets" >Secrets</a>.
</div>

</div>

<div class="rs-ckey" id="version">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">version</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>string</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>v2</code>
  </p>
<p class="rs-ckey__field">
  Description:
  TikTok Events API version for cloud mode.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>v2</code> or <code>v1</code>. Use <code>v2</code> — TikTok announced the sunset of Events API 1.0.</li>
<li>A <code>{{ path || fallback }}</code> template is accepted in place of a literal.</li>
</ul>

</div>

</div>

<div class="rs-ckey" id="hash_user_properties">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">hash_user_properties</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>true</code>
  </p>
<p class="rs-ckey__field">
  Description:
  SHA-256 hash contextual user properties such as <code>external_id</code>, <code>email</code>, and <code>phone_number</code> before sending them.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>Applies to <code>cloud</code> mode only.</li>
</ul>

</div>

</div>

</div>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="event-mapping">Event mapping</h3><div class="rs-ckeys">
<div class="rs-ckey" id="events_to_standard">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">events_to_standard</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>array of objects</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Maps RudderStack event names to TikTok standard events. Events without a mapping follow the default mapping in <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/tiktok-ads/cloud-mode/#event-mapping" >Event mapping</a>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>from</code> — RudderStack event name. At most 100 characters, and must not contain line breaks.</li>
<li><code>to</code> — one of <code>AddPaymentInfo</code>, <code>AddToCart</code>, <code>AddToWishlist</code>, <code>ClickButton</code>, <code>CompletePayment</code>, <code>CompleteRegistration</code>, <code>Contact</code>, <code>Download</code>, <code>InitiateCheckout</code>, <code>PlaceAnOrder</code>, <code>Search</code>, <code>SubmitForm</code>, <code>Subscribe</code>, <code>ViewContent</code>, <code>CustomizeProduct</code>, <code>FindLocation</code>, <code>Schedule</code>, <code>Purchase</code>, <code>Lead</code>, <code>ApplicationApproval</code>, <code>SubmitApplication</code>, or <code>StartTrial</code>.</li>
<li>Both fields accept a <code>{{ path || fallback }}</code> template in place of a literal.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">events_to_standard:
  - from: Order Completed
    to: CompletePayment</code></pre></div>
</div>

</div>

</div>

<div class="rs-ckey" id="send_custom_events">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">send_custom_events</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>boolean</code>
  </p><p class="rs-ckey__field">
    Default value:
    <code>false</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Send events that don&rsquo;t map to a standard event as TikTok custom events. For custom events, only TikTok&rsquo;s standard fields are sent; other fields are dropped.
</p>

</div>

</div>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="event-filtering">Event filtering</h3>
<blockquote class="warning">
  <div class="tip-quote">
    
    <div class="tip-text"><a href="https://www.rudderstack.com/docs/sources/event-streams/sdks/event-filtering/" >Client-side event filtering</a> is applied by the RudderStack SDK, so it affects only web sources connected in <code>device</code> mode. Events sent in <code>cloud</code> mode reach TikTok unfiltered, whatever this block says.</div>
  </div>
</blockquote>
<div class="rs-ckeys">
<div class="rs-ckey" id="event_filtering">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">event_filtering</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Restricts which <code>track</code> events the SDK passes to the TikTok pixel, by event name.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li><code>whitelist</code> — array of event names to allow; every other <code>track</code> event is dropped.</li>
<li><code>blacklist</code> — array of event names to drop; every other <code>track</code> event is allowed.</li>
<li>The two are mutually exclusive, and Rudder CLI enforces it — setting both fails validation.</li>
<li>Each name is at most 100 characters, or a <code>{{ path || fallback }}</code> template.</li>
<li>Omit the block entirely to filter nothing.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">event_filtering:
  blacklist:
    - Product Viewed</code></pre></div>
</div>

</div>

</div>

</div>

<!-- end-chunk -->
<!-- begin-chunk -->
<h3 id="per-source-keys">Per-source keys</h3><p>Both keys are objects keyed by the local source type — the tokens listed under <a href="#source-types" >Source types</a>. A key naming a source type this destination doesn&rsquo;t support fails validation.</p>
<div class="rs-ckeys">
<div class="rs-ckey" id="connection_mode">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">connection_mode</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Maps each source type you connect to the mode its events reach TikTok in, using the modes in <a href="#source-types" >Source types</a>.
</p>

<div class="rs-ckey__notes">
  <p class="rs-ckey__field">Notes:</p>
  <ul>
<li>An entry is required for each source type you connect — see <a href="#connect-a-source" >Connect a source</a>.</li>
<li>A mode the source type doesn&rsquo;t support on this destination fails validation — for example <code>device</code> for <code>android</code>.</li>
</ul>

</div>

<div class="rs-ckey__extra">
  <div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">connection_mode:
  web: device
  cloud: cloud</code></pre></div>
</div>

</div>

</div>

<div class="rs-ckey" id="consent_management">
  <div class="rs-ckey__title">
    <p class="rs-ckey__name">consent_management</p></div>
  <p class="rs-ckey__field">
    Type:
    <code>object</code>
  </p>
<p class="rs-ckey__field">
  Description:
  Consent provider configuration per source type. The entry shape, accepted providers, and the rules on <code>resolution_strategy</code> and <code>consents</code> are shared across all destination types — see <a href="https://www.rudderstack.com/docs/dev-tools/rudder-cli/destination-types/#consent-management" >Consent management</a>.
</p>

</div>

</div>

<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="source-types">Source types</h2><p>TikTok Ads accepts events from these source types in the mentioned connection modes:</p>
<table>
<thead>
<tr>
<th>Source type</th>
<th>Connection mode</th>
</tr>
</thead>
<tbody>
<tr>
<td><code>android</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>android_kotlin</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>ios</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>ios_swift</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>web</code></td>
<td><code>cloud</code>, <code>device</code></td>
</tr>
<tr>
<td><code>unity</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>react_native</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>flutter</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>cordova</code></td>
<td><code>cloud</code></td>
</tr>
<tr>
<td><code>cloud</code></td>
<td><code>cloud</code></td>
</tr>
</tbody>
</table>
<p>Only <code>web</code> offers <code>device</code> mode, which loads the TikTok pixel in the browser. See <a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/tiktok-ads/device-mode/" >TikTok Ads device mode</a> and <a href="https://www.rudderstack.com/docs/destinations/rudderstack-connection-modes/" >RudderStack Connection Modes</a>.</p>

<html lang="en">
<blockquote class="info">
  <div class="tip-quote">
    
    <div class="tip-text">The dashboard additionally offers TikTok Ads to AMP, Shopify, and Reverse ETL sources. Rudder CLI doesn&rsquo;t manage those connections, so <code>amp</code>, <code>shopify</code>, and <code>warehouse</code> are invalid here.</div>
  </div>
</blockquote>

</html>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="connect-a-source">Connect a source</h2><p>An event stream connection to this destination is checked against two rules at <code>validate</code> time.</p>
<p><strong>The source&rsquo;s type must be supported.</strong> A source&rsquo;s type resolves to one of the tokens above before the check — a JavaScript source resolves to <code>web</code>, and webhook and server-side SDK sources resolve to <code>cloud</code>. An unsupported type reports:</p>
<div class="rs-code">
  <div class="rs-code__head"><button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-text" data-lang="text">destination &#39;tiktok-ads-prod&#39; (type &#39;tiktok_ads&#39;) does not support source &#39;my-source&#39;:
source type &#39;amp&#39; is not among supported source types: android, android_kotlin, ...</code></pre></div>
</div>
<p><strong>The destination config must carry a <code>connection_mode</code> entry for that source type.</strong> This lives on the destination spec, not on the <a href="https://www.rudderstack.com/docs/dev-tools/rudder-cli/yaml-connections/" >connection spec</a>. Without it:</p>
<div class="rs-code">
  <div class="rs-code__head"><button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-text" data-lang="text">destination &#39;tiktok-ads-prod&#39; config has no &#39;connection_mode&#39; entry for source type &#39;web&#39;</code></pre></div>
</div>
<p>TikTok Ads needs no additional config keys to connect a source of any type, in any mode.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="secrets">Secrets</h2><p><code>pixel_code</code> and <code>access_token</code> are the secret keys. Write each as a <code>{{ .VAR }}</code> reference and supply the value at apply time:</p>
<div class="rs-code">
  <div class="rs-code__head">yaml<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-yaml" data-lang="yaml">config:
  pixel_code: &#34;{{ .TIKTOK_PIXEL_CODE }}&#34;
  access_token: &#34;{{ .TIKTOK_ACCESS_TOKEN }}&#34;</code></pre></div>
</div>
<div class="rs-code">
  <div class="rs-code__head">bash<button class="rs-code__copy" type="button">
      
      Copy
    </button>
  </div>
  <div class="highlight"><pre class="chroma"><code class="language-bash" data-lang="bash">export RUDDER_TIKTOK_PIXEL_CODE=&#34;...&#34;
export RUDDER_TIKTOK_ACCESS_TOKEN=&#34;...&#34;
rudder-cli apply

# or
rudder-cli apply --var-file secrets.vars.yaml</code></pre></div>
</div>
<p>Note that:</p>
<ul>
<li>The YAML that <code>rudder-cli import</code> writes may or may not include secret keys. Before you apply, make sure every secret key your configuration needs is present and populated through variable substitution.</li>
<li>In device mode the pixel code is embedded in the page&rsquo;s JavaScript, so treating it as a secret protects your YAML, not the value itself.</li>
</ul>
<p>See <a href="https://www.rudderstack.com/docs/dev-tools/rudder-cli/variable-substitution/" >How to Use Variable Substitution in Rudder CLI</a>.</p>
<!-- end-chunk -->
<!-- begin-chunk -->
<h2 id="see-more">See more</h2><ul>
<li><a href="https://www.rudderstack.com/docs/destinations/streaming-destinations/tiktok-ads/setup/" >TikTok Ads Destination</a> for pixel setup and verifying delivery</li>
<li><a href="https://www.rudderstack.com/docs/dev-tools/rudder-cli/destination-types/" >Destination Type Reference for Rudder CLI</a> for the rules shared across destination types</li>
<li><a href="https://www.rudderstack.com/docs/dev-tools/rudder-cli/yaml-destinations/" >Destination YAML Reference</a> for the spec envelope</li>
</ul>

