Halp Dev Corner
August 22, 2019

Your metrics for your Slack App are wrong. Here's how to fix them

So you've created a Slack App, that's awesome. It's pretty likely that you're not getting the right data about traffic and installations from Slack. Learn how to make sure you're tracking everything correctly.

If you are building a B2B product today, it is basically mandatory to have a great Slack App. It’s the primary collaboration tool for companies small and big and enables you to create thoughtful interactions with users in the environment they are working out of all day, every day. Seems like a no brainer right? 🧠

Once you have a Slack App, you can list it in the Slack App Directory, which is a great place to drive new customers to your product. Whether you have a simple integration, or you’re building a “Slack-first” product, the App Directory puts you in front of the hundreds of thousands of companies using Slack every day.

However, there are a couple of tricky, non-obvious "gotchas" about measuring traffic and installations from the Slack App Directory. 

The Slack App metrics you're probably tracking wrong

Slack by default removes referrer information from all links clicked in Slack, and this includes links from the App Directory. This means when someone clicks the link to visit your site from Slack App Directory listing, it will by default appear as Direct traffic. This isn’t great, because you aren’t able to measure how much awesome traffic you’re getting from the Slack App Directory!

When someone clicks the “Add to Slack” button on your site to authorize Slack, when they land back on your page, the referrer gets set as Slack, which in this case may not be correct! The problem with this is that if someone came from somewhere besides Slack and installed your Slack App, the referrer will be incorrect. 

Without being able to track where sign-ups are coming from, you’re basically flying blind 🙈. But have no fear, we’ve figured out a way to solve both of these problems. We’ve set up a nice little system to track installs for our Slack App from both the App Directory (which is one of our best performing channels) and any other channel. 


Tracking Traffic Correctly from the Slack App Directory

The first step is to add a parameter to your Installation Landing page link in your Slack App Directory listing. This is in Development App -> Settings -> Basic Information.



The key here is adding the ?ref=slack parameter. 

Next, you’re going to add a javascript snippet to your website that looks for this parameter and sets the referrer based on that ?ref=slack parameter. 

You can add this directly to your site or using Google Tag Manager. 

Here’s what that looks like:



🎉! There ya go. You will now see traffic hitting your landing page marked correctly in Google Analytics with the referrer “slack.com”. First problem, solved! 🕵️‍♀️


Correctly Tracking the Referrer for Installs of Your Slack App


When someone clicks the “Add to Slack” button on your site, we need to grab the referrer and store it in a state variable in the OAuth URL. 



There is probably more than one place where you have an “Add to Slack” button on your site, so we are dynamically setting the URL of that add to Slack button here based on something with the data value: slack-button=clickable, which we set in our HTML of each button. That way we only have to update our URL in one place if it ever changes. 


Next, we store the referrer in a state variable, encode it, and append it to our URL dynamically.

Once again this can be added directly to your site or using Google Tag Manager.


Finally, on the landing page where a user ends up after completing authorization, we need to decode the referrer and set it as the official referrer for tracking. This script should only fire on the page a user lands on after adding to Slack. For us, this is a welcome page. 




Booya! All of your conversions will now be attributed to the correct referral source, so you’ll finally know where all those great new customers are coming from :), and those pesky marketers can sleep better at night.

Liked this article? Sign up and subscribe for more tips!

Read what's next

Discover

The First Slack-based Ticketing For Modern IT Teams.

Learn About Our Solutions