Send Slack Notifications Using Google Tag Manager Server Container

We created a tag for the Google Tag Manager server container that sends a notification to Slack. With the help of this tag, you can send any information about user actions on your site to the Slack channel. This tag allows adding variables, such as product and user information inside the notification. You can notify your team about a new purchase, abandoned cart, or a new quote request from clients. One of the use cases of this tag is to send slack notifications about new orders to the sales team slack channel. You can also use this tag to monitor your site stability.

How does the Slack tag for the Google Tag Manager Server container work?

To send Slack notifications, you will need to have a configured Google Tag Manager Server container with the user and event data you want to send inside the slack message. You will also need to create a Slack app and generate a webhook URL for this app. It may sound complicated, but everything can be set up in a few clicks. I will cover all steps in this how-to, including creating a Slack app and webhook URL.

Use Slack tag to test if Facebook tracking is blocked by iOS 14

One of the non-standard use cases of the Slack tag is to verify whether Facebook conversion tracking was blocked for iOS 14 users who opted out of tracking or not. Let’s say you’ve implemented Facebook conversion API and using a custom subdomain for the tagging server. You see events in the test events tool inside the Facebook business manager, but how to verify that Facebook conversion tracking works for iOS 14 users who opted out of tracking.

You can set up Slack Tags that will use the same trigger as your Facebook CAPI tags. Open your FB ad on the iPhone that opted out of Facebook tracking, click on the ad, and test events. If tracking works, you will see Slack notifications. Since Slack and Facebook use the same triggers, you can say that Facebook tracking works too. 

How to send Slack notifications using the Google Tag Manager server container?

  1. Set up a Google Tag Manager Server container
  2. Open Server container and add Slack tag from the template gallery or by clicking this link.

slack tag for google tag manager server container

3. In this example, I will show how to send a Slack notification on a successful purchase. First of all, you need to make sure that the Server container has the required purchase information. If not, you will need to configure it. 

Let me show you how to send data from the web to the server container. I have a data layer inside the Web container with order information. I will use the GA4 tag to send data from the web to the server container. Inside the Web container, I’ve set up a GA4 Configuration tag with the configured transport URL that sends requests to my tagging server URL. I also set up a GA4 Purchase Event with purchase details.

GA4 base server-side

GA4 server even purchase

4. Inside the Server container, I’ve added a GA4 Client and GA4 tag that triggers every time a GA4 client is claimed.

GA4 client server container

GA4 tag inside the server container

5. Open the preview mode of the Web and Server container and check that the Server container sees order data.

test GA4 tag in the server Container

6. Create variables inside the Server container that will take event data. Variable type Event Data -> Add Key Path -> Click Save. We will use these variables for the Slack notification. 

user data GA4 server side

7. Go to the Tags tab inside the Server container -> Click New -> Tag type Slack Notification. 

8. We will need to create a Slack App and then generate a Webhook for it. Click this link -> Click Create An App -> Select From scratch -> Name your App and select Slack Workspace.

slack build app

slack build app from scratch

slack build app select workspace

9. Generate an incoming webhook for the app that we’ve recently created. Click Incoming Webhook -> click the Activate Incoming Webhooks toggle to switch it on -> scroll down and click Add New Webhook to Workspace -> Select channel you want to send notifications to and click Allow -> Copy the Webhook URL.

slack app activate incoming webhook

slack app add webhook to workscpace

slack app select slack channel

10. Paste Webhook URL inside the Slack Tag. 

copy slack webhoook URL

add slack webhook url to slack tag

11. Create a Slack notification text. You can add variables here. Add a trigger and click save.

slack notification tag

trigger for the slack tag

12. Open the preview mode of the Web and Server containers and test that notification works.

test slack tag for server container

13. Publish web and server containers.   

Conclusion

The developers and organizations are continuously looking for new solutions to facilitate their workflow with Slack better. I hope this post helped you set up Slack notifications for the critical events on your site.