Send Telegram notifications using Google Tag Manager Server container

Let’s say you started a new campaign or launched a website and want to receive real-time notifications about new orders. Checking conversions inside Google Analytics can be time-consuming. So what is the best way to send information about user activity on your site or orders from specific traffic sources? We create a Telegram tag for the Google Tag Manager Server container that can send notifications about user actions on the website to the Telegram channel. We also have a similar tag for Slack notifications.  

Using the Telegram tag for the Google Tag Manager server container, you can receive real-time Telegram notifications on every conversion or any other user action on the site. The notification can be sent to multiple recipients.  

You can also use the Telegram tag to send notifications about errors on your site. It’s an easy way to monitor user activity on the site.

How does the Telegram Tag for Google Tag Manager server container work?

Whenever a conversion takes place, a message got pushed into the channel. You can send user or order details inside the Telegram notification. You can add any information you can get using Google Tag Manager into a Telegram message. It may be, for example, a traffic source, product name, or category. You can send notifications into different channels depending on what traffic source is responsible for the conversion.  The subscribers can be you, developers, SEO manager, PPC manager, developers, etc.

Telegram tag communicates with telegram API. All setup is done inside the Google Tag Manager server container. 

How to send Telegram notification using Google Tag Manager server container?

  1. Set up a Google Tag Manager server container
  2. Send required data from Web to Server container. This guide will show how to use the GA4 tag to get data inside the server container. The first step would be to set up server-side GA4 inside the Web container. Add transport URL to the GA4 Configuration tag and set up GA4 event tags that will include required user and event parameters.
GA4 base server-side
GA4 server even purchase

3. Go to the Server container and add a GA4 client inside the Server container and create a GA4 tag that will trigger all requests from the GA4 client. 

GA4 client server container

GA4 tag inside the server container

4. Create variables inside the Server container that take required event data. 

user data GA4 server side

test GA4 tag in the server Container

5. Add a Telegram tag to the Server container. You can add it from the Template gallery or by clicking this link

telegram tag for server container

6. Create a new tag inside the Server container -> Tag type Telegram Notification.

7. You will need to add an Access Token inside the Telegram tag. (here is a link to a detailed description of how to create an Access token) To create a new bot click this link, it will open the Telegram app -> click start -> type command /newbot -> Telegram will ask you to create bot name -> on the next step it will ask you to create a username of your bot, it should end with _bot -> you should see the message that your bot was created and access token for this bot -> copy access token and add it inside the Telegram tag.

create telegram bot

set up API token telegram

 

8. Add the channel name. To create a new channel, click on the menu on the top left corner. You need to create a public channel. 

create new channel telegram

9. Open the channel that you’ve recently created and invite the bot you’ve created on step #7. To do that click manage users -> add bot name -> click add. 

add user to telegram channel

add telegram bot to the channel

10. Add Notification Text. You can add variables inside the notification text. Add a trigger for the tag. In my case, Telegram notification will trigger on a successful purchase.

trigger for the slack tag

telegram tag on purchase

11. Open the preview mode of the web and server container and test the Telegram tag. If everything works correctly, you will see a message in the telegram channel, and the tag status will be Succeeded.

send telegram notification on successful purchase

telegram tag for google tag manager server container

Conclusion:

And that’s it! You’ve just sent a real-time Telegram message whenever someone converts on your website, with the user and product parameters. You can upgrade the trigger so it will work only for special products, traffic sources, or only when transaction revenue is more than X.