Published July 8th, 2019 by Assaf Trafikant

Real-Time Conversion Notifications On Telegram

A few weeks ago, we ran a campaign and had to get live updates from website conversions. We didn’t want to do it via Google Analytics because of the delay. The same goes for Google and Facebook. The only thing that isn’t delayed is the conversion itself. So we hypothesized that any system that catches the conversion in real-time could also notify us about it.

In this particular case, we could have used Zapier or any similar tool, connect it to a CRM or Magento, and start getting your notifications anywhere, anytime. But if you know me and have been following this blog for a while, you know that I don’t like to rely on third parties. If there’s a process I can build without relying on a third party, especially if I can do it for free, that’s the road I’m going to take. The question was how exactly I was going to do it.

While thinking about a solution, I received my daily campaign summary on Telegram. That’s when it clicked: I had to do it via Telegram. It has a wild, efficient, simple, and stable API, and our clients and I all use it anyway, so why not?

How? It’s all laid out here in this article, step-by-step just as we had done it ourselves. We started with a mockup of the result, then drilled down to a basic version, which we gradually upgraded. You should (naturally) read from the beginning to get the full context. And another thing – the messages are all made up because I can’t reveal our clients’ information.

The Goal

To receive real-time Telegram notifications on every site conversion. The notification should be sent to multiple recipients. This is what we wanted it to look like this mockup:

The Prototype

We created a designated Telegram channel for our client (let’s pretend it was Tesla), which we named Quickwin Conversions – Tesla. Whenever a conversion took place, a message got pushed into the channel. The subscribers were my campaign managers, my client, and myself. The channel is private (of course), so you can’t find it in on Telegram without a link. Because we had many campaigns running simultaneously, we wanted to know what was the source of each conversion. Facebook? Google? Mailing list? We decided to take it a step further, take the user’s UTMs (if there were any), and put those in the message as well. Now it looked like this mockup:

What About Google Ads Campaigns?

Campaigns that don’t have UTMs, such as Google Ads campaigns, give us Google’s GCLID, but on a technical level, we can’t ask Google about the GCLID and get the data we want. The only way around it is pretty convoluted, and we didn’t want to get into that. So we added a logic that simply checks if there’s a GCLID. The value didn’t matter; we just wanted to know if there was or wasn’t one. If there was, our message said (Google Ads) instead of the UTMs.
It’s important to mention that there’s no real, profound attribution here. The user could have reached the site organically on their second visit, even if they clicked a Facebook ad the week before, and god knows what they did in between. It was only meant to give us a clue as to where the conversion may have come from. Nothing more. And it was AWESOME.

Notifications started coming in as soon as the conversion took place, and we even had information about their source. We later incorporated Yaniv Calisar’s script, which takes the UTM from the first and last visits and saves them as cookies. We extracted this information from the cookies to include information on the first and last sources in our notification. Everyone was happy for a while.

Notifications started coming in as soon as the conversion took place, and we even had information about their source. We later incorporated Yanir Calisar’s script, which takes the UTM from the first and last visits and saves them as cookies. We extracted this information from the cookies to include information on the first and last sources in our notification. Everyone was happy for a while.

A few days later, the client wanted to add to each notification, the transaction number, revenue, and whatever we could tell him about the conversions. So we did it like in this mockup:

The Entire Process – Step By Step

A small request before we begin: Did you follow the instructions, and everything worked? Are you and your clients enjoying it? Write in the comments if it worked (or didn’t). Now let’s get to it.

Part 1 – The Rules

  • The mechanism is designed for website conversions. Forms, eCommerce transactions (first, be sure that Google Analytics e-commerce data is correct), mailing list registration, whatever – as long as it took place on your website, it’s going to work. That means that it won’t work for Facebook lead campaigns or offline store.
  • We use Google Tag Manager conversion trigger that you might already have.
  • Some browsers don’t really like this technique, and you might get some alerts on your DevTools console. You can ignore those errors.
  • If you’re running tests and keep getting multiple notifications with the same content all at once, even though you only had one conversion, it’s a Chrome glitch. It only happens if you’re running the Tag Assistant extension. Why? Beats me.
  • Read first, try later.

Part 2 – Creating A Telegram Channel

To start, you have to create a Telegram channel, which means only you can broadcast, and no one can respond.

  • Open Telegram from your mobile phone
  • Create a new private channel and name it something that has your name (or company’s name) and your client’s. If, say, my client is Pampers, I’ll call the channel Pampers Live Conversions by Quickwin and add a branded avatar.
  • Now, you’ll get a link to send out to whomever you want to be a part of this channel. The next screen will let you choose the contacts you want to invite to the channel. If there aren’t any just yet, don’t pick anyone – just go back using the top arrow until you’re back at the home screen. The channel will be there, waiting.

Part 3 – Chat ID

Now go into Telegram again, but this time using your desktop (Telegram Web). Your new channel will appear at the top of the list. Click the channel name and look at the URL address in your browser. It should read something like this:

Copy the 10 digits after ‘?p=c’ (444333221 in my example) and paste them in Notepad or someplace similar. That’s the channel ID. We’ll use it in a minute.

Part 4 – Creating Telegram Bot

The next step is to create the engine that sends messages to the channel, and that engine is called a bot. That’s right, Telegram has an awesome and relatively easy-to-build bot service, and that’s what’s going to be in charge of sending out the messages to the channel.

To create a new bot, make sure Telegram Web is still open on your desktop and then click here. You’ll see some new guy on Telegram, called TheBotFather – that’s a cool Telegram’s bot, and it can create bots for you. A bot maker bot! How futuristic. To start chatting with it, type /start and the bot will respond by providing you with a billion commands that let you control it. Here’s what it looks like:

  • Type /newbot to create a new bot. The BotFather will ask you for a name.
  • Name your bot whatever you’d like; you’re the only one who’s going to see it. You can use spaces, numbers or whatever. I suggest you choose something that contains the customer name, e.g. Pampers Conversion Bot.
  • Now The BotFather will ask you to give your bot a unique username, one that no other bot has. That’s the bot’s @handle. If the name is already taken, The BotFather will let you know. You can’t use spaces, and it has to end with the word bot (no punctuation marks). So in our case, PampersConversionBot.
  • When you’re done, The BotFather will let you know, and you’ll even get a special token in red. Keep it, we’re going to use it in just a moment. If you want, you can reset it later and get a new token instead.

Part 5 – Connect The Bot To Your Channel

The next step is to assign your bot permissions to write to the channel. Go to your channel (preferably via mobile), click Channel and you’ll see a screen with the list of subscribers. Click Administrators, then Add Administrator. Now click the search icon and search for your bot – not the long name, but the handle that ends in bot. No need for the @. Add it as an admin.

Congratulations, you have a bot that can send out messages to the channel. Excellent. The last thing to do is make sure that GTM sends a message to the bot, and the bot will make sure to pass it on to the channel.

Part 6 – Google Tag Manager Setup

Create a new HTML tag with the following script.

<script src=""></script>
  • Replace XXXXXX with the red token, you got from TheBotFather earlier.
  • Replace AAAAAA with the 10-digit number from the beginning of the article.
  • Keep the text “Message” at the end. We’ll change it later. First, we need to test.

Assign your conversion trigger, or if you wish, assign a simpler trigger, like viewing a specific page or clicking a test button. Make sure it works before moving on. If you’re receiving false notifications or errors in your console, remember what I wrote in Part 1.

Part 7 – upgrading the message

So we have a bot, a channel, and a tag that runs whenever there’s a conversion and sends out whatever text we want to anyone on the channel. If you’re familiar with Google Tag Manager, you can start playing around with the variables you already have and send out any piece of information that you acquired beforehand. To do that, create a constant type Variable called Telegram Message. This variable can be a chain of other variables and free text. We’ll see the word “Sale”, followed by the transaction number, amount, and other parameters. The variable can look like this, or any other way you want it:

Now we have to go back to the Telegram tag we created earlier, and replace the free text with the variable we created:

And we’re done! You’ve got a real-time Telegram message sent out whenever a conversion takes place; it has everything you need, and you can go wild with the final message, and some personalization, emojis, whatever. You can upgrade the trigger so it will work only for special products, or only when the transaction revenue is more than $X.
Questions, comments, or requests for more complex integrations? I’m waiting for your feedback.

More Articles

All articles

My Extensions

  • Analytics UTM Builder

    50,000+ USERS

    • Star
    • Star
    • Star
    • Star
    • Star


  • Data Studio Auto Refresh

    1,000+ USERS

    • Star
    • Star
    • Star
    • Star
    • Star


  • No Stress Booking

    10,000+ USERS

    • Star
    • Star
    • Star
    • Star
    • Star