getButterfly
Resume

NAVIGATION

ATTRIBUTION

getButterfly
Dublin, Ireland

All Content Copyright ©2019
getButterfly

How to post to Slack using a third-party script

Or Google Tag Manager, whichever is handier.

Here’s a short snippet of code I used to use to notify my team of recent conversions, as they took place. The delay was less than 3 seconds.

Slack Logos
<script>
let url = 'https://hooks.slack.com/services/XXXXXXXXX/YYYYYYYYY/ZZZZZZZZZZZZZZZZZZZZZZ';
let text = 'New event - {{customEventId}} - completed!';

$.ajax({
    data: 'payload=' + JSON.stringify({
        "text": text,
    }),
    dataType: 'json',
    processData: false,
    type: 'POST',
    url: url
});
</script>

Notes & Details

  1. Get the hook URL from Slack.
  2. I initially used jQuery for this, but it can be easily switched to use XHR or Fetch API. It’s pretty old, though, and I won’t do it. I’m not using Slack anymore.
  3. {{customEventId}} is a Google Tag Manager variable.

Added by Ciprian on Friday, July 5, 2019 in Blog

Do you want better SEO? More traffic? More conversions? More growth? We help companies exponentially grow their traffic and conversions, while outranking their competitors. With more than 10 years of experience, we’ve learned what is valuable to our clients.
SEO Dublin | SEO Malta

My Battle Tested Recommendations

Jetpack
Dreamhost
WordPress.com
CodeCanyon
SEMrush

Disclaimer: These recommendations contain affiliate links.


Privacy Policy