How to set up Snapchat Conversion API using server Google Tag Manager

April 03, 2022
Also available in

Tracking restrictions have a massive effect on the accuracy of analytics data. iOS updates caused the biggest problem for web and app trackers. The latest update from Apple has caused quite an issue among businesses relying on advertising - all apps must ask the user’s permission before using any trackers. 

According to recent research, around 80% of users opt out of tracking. It’s highly affected on apps whose main profit relies on advertising, such as Facebook, TikTok, and Snapchat. These companies started asking advertisers to implement server-side tracking to improve data quality.

We already have blog posts on setting up Facebook CAPI and TikTok Events API. In this blog post, I will talk about Snapchat Conversion API and how to set it up using the server Google Tag Manager container.

About Snapchat conversion APICopy link to this section

 Snap Conversions API allows passing web, app, and offline events from your server to Snap servers. The official documentation says that Snap CAPI helps lower cost per action by improving conversion tracking and targeting.

Snapchat CAPI supports the same events and event parameters as web pixels. There are two main ways of implementing Snap CAPI: direct integration, which means sending server-side information from your servers directly into Snap’s servers, or partner integrations that include server Google Tag Manager (GTM). 

Stape team created Snap Conversion API tag for the server Google Tag Manager container. The logic of Snap tag is more complicated than FB or TikTok, making implementation of Snap CAPI more time-consuming. We tried to make Snap CAPI setup for stape users more straightforward. In this blog post, we will show how to use it. 

Snapchat event deduplication. Similar to Facebook and TikTok, Snapchat supports event deduplication, which means you can use both browser and server tracking. To remove redundant events, you should use event deduplication. The primary deduplication keys are Client_dedup_id (Which allows for a 48-hour deduplication window) and Transaction_id (Allows for a 30-day deduplication window).

Cookies are still one of the most effective ways to track users. So till cookies are fully deprecated, most platforms, including Snap, recommend using web+server tracking. 

Snap tag for web Google Tag Manager does not support event_id, meaning that you should use a Custom HTML tag in web GTM to set up event deduplication. 

Snapchat CAPI events: CAPI supports all types of standard event names available for Snap web pixel. It also supports custom event names. 

Event parameters. Snapchat has detailed documentation that describes what event parameters CAPI supports. Click this link to check it. All user parameters (plain text email, mobile identifier, IP address, and phone number) should be normalized. After parameters are normalized, they should be hashed with lowercase hex SHA256 format.

Server event testing. Though Snapchat has excellent functionality for testing pixel events using the pixel diagnostics page, unfortunately, for now, Spanchat does not have functionality for testing server events in real-time, similar to FB’s test ID.

The only way to check that Snap received and processed server data correctly is by checking via Conversion API data in the Snap events manager.

Auth requirements. Snapchat controls all permission and requests to the Marketing API using Access Tokens. To set up Snapchat CAPI, it’s required to obtain an Access Token. Snapchat access tokens are short-lived. That is why we used Firestore to refresh Snap Access Tokens. I will show how to generate Snap Access Token in this blog post.

Benefits of Snapchat conversion APICopy link to this section

Privacy. Server to server tracking, at its core, is a technology building with a privacy policy in mind. Unlike web pixel tracking, with s2s tracking, you can strictly control which data you send to each network. They will receive only data configured in server requests. 

Better ads optimization. CAPI helps collect more data about users, making Snap advertising algorithms more sufficient. In the official documentation, Snapchat says that implementing CAPI will help to improve cost per action. 

More quality audience. CAPI will improve remarketing and lookalike campaigns since it will send Snapchat more data about your users. The number of events should also increase. When users do not allow apps or sites to track users, CAPI can still be used to send events. 

Improved conversion tracking. Since server events can't be blocked in most cases, it will allow users to track all events generated by users.

How sGTM Snapchat conversion API tag worksCopy link to this section

The logic of the Snapchat CAPI tag is more complicated than Facebook’s and TikTok's due to Snap verification requirements. It’s required to use Access Tokens to send server events to Snap. Access Tokens that Snapchat generates are short-lived. When the Token expires, Snapchat sends a 401 token expired error. It is necessary to renew Access Token using Refresh Access Token and send the request again. 

Stape Snap CAPI tag uses Firebase to get and store Access Token. The logic of this tag is described in the diagram below. 

The requirements for setting up this tag are different for stape users and non-stape users.

If you use stape, you will need to create a Firebase account, create a Google Services account and link it to your stape account. I will show you how to do it later in this blog post. 

If you do not use stape, you’ll need to independently handle Access Token's refresh process. Check Snap Marketing API documentation for more details. 

What do you need to set up Snapchat conversion APICopy link to this section

1. Snapchat pixelCopy link to this section

This one is easy to find. Follow these steps to create a Snap pixel. 

2. OAuth AppCopy link to this section

OAuth App is required to create Client ID, Client Secret and API Refresh Token that you will need to set up a Snap sGTM tag. To create an OAuth App, you need to have Organization Admin permission.

Open Snap Business Manager -> Click Business Details -> Click +OAuth Apps -> Add App Name -> Add Snap Redirect URI. If you use stape for setting up Snap CAPI, use this value: 

If you do not use stape, you need to create a Redirect URI. 


3. Client ID and Client SecretCopy link to this section

This one is required to set up a Snap tag. It will be generated once you create OAuth Apps. 


Save the Snap Client Secret Key.

Make sure to save the Snap Client Secret Key. It won't be available again.

4. Google service accountCopy link to this section

    1. Open your account -> Open sGTM container -> Click Power-Ups -> Click Config under Google service account.

    2. Log in to the Google Cloud account (or create one) -> From the Navigation menu on the top left corner, select IAM & Admin -> Service Accounts -> Click Create service account. 

    3. Add account -> Click Next -> Select Roles BigQuery Data Editor role for BigQuery access or the Cloud Datastore User role for Firestore. 

On the third step, click no need to select anything; just click Done. 

    4. Open the service account that you’ve recently created -> Open Keys tab -> Click Add Key -> Select JSON type in the popup -> Click create. A file will be downloaded to your computer. 

    5. Go back to the account -> Upload key that you’ve recently generated -> Click Save.  

5. Firebase accountCopy link to this section

    1. Open -> click create project -> select project that you’ve used on Google Cloud -> click continue -> click Add Firebase on the third step. 

    2. Click Build -> Firestore Database. 

    3. Click create database -> select Start in production mode -> Click Next

    4. Select the region of your firebase. It should match the region of your sGTM server location. You can check the region by opening a account -> opening the sGTM container -> check Server Location. To match the sGTM server location with Firebase, please check this link.  

    5. Click Start a collection. Here you will need to set Firebase Path that lately will be used in CAPI Snap Tag. I’ve added Document parent path /stape-demo and Document ID Snapchat-auth -> Click Save.

6. API Refresh TokenCopy link to this section

If you do not use stape, follow Snap doc on creating API Refresh Token. If you use stape, please follow these steps:

    1. log in to your stape account and click Tools -> Snapchat Authentication helper -> Add Snap Client ID created on step 3 -> Start authorization. 

    2. You will be redirected to the Snap authorization page. Finish authorization. 

    3. Add Client ID, Client Secret and click Generate Refresh Token. 

    4. On the next screen, you will see Snap Refresh Token. You will need this refresh token to set up Snap Tag. Copy refresh token. 

How to set up Snapchat conversion API using server Google Tag ManagerCopy link to this section

2. Send data to the server GTM container. The two most popular sending data to sGTM are Google Analytics 4 and Data Tag/Data Client.

3. Download the Snapchat tag from GitHub or add it from sGTM template Gallery -> Open templates sections in the server Google Tag Manager container -> Click New.

4. Click three dots in the top right corner -> Click Import -> Select the Snapchat tag template you’ve recently downloaded from GitHub -> Click save.

5. Create Snap tag in sGTM container -> Select event name. 

Standard - select one of the standard names.

Inherit from the client - in this case, the tag will try to parse sGTM event names and match them to Snap standard events. 

Custom - use a custom name. 

6. Add Snap Pixel ID -> Add API Refresh Token. We’ve described how to generate it earlier in this article -> Add Client ID and Client Secret.

7. Open the Firebase Settings section of the tag and add Firebase Path

8. Add user and events data. 

9. If you want to use hybrid method (web+server) tracking for Snap, make sure you’ve added event ID to web and server Snap tags. For now, the web Snap tag does not support event_id, so use custom HTML to set up Snap web tags. 

10. Open web and server GTM debugs and tests that Snap tags are triggered correctly. 

11. Unfortunately, Snap does not have a tool that helps troubleshoot server events in real-time. The only option to verify that Snap received server events is waiting till you see these events in Snap Events Manager. 

ConclusionCopy link to this section

Snap official documentation says that implementing Conversion API will help to improve bidding and decrease cost per action. Though implementing is more complicated than FB or TikTok, it might help to improve the results of your paid campaigns. 

If you need help setting up server-side tracking for Snapchat Conversion API, don't hesitate to contact us. Our team of experts is more than happy to assist you in getting started. Thanks for reading!

Tagged with:sGTM tag

Host your GTM server at Stape

By signing up you agree to Stape’s Terms of Use and Privacy Notice