slack-google-analytics

This is my second post on using Slackalytics. If you haven’t already set up Google Analytics and Slack, check out my previous post on Customizing and Setting Up Reports Using Slackalytics.

In this post we’ll take a look at how to pass emojis and @mentions in to Google Analytics.

New Custom Dimensions

For both of these tasks, we’ll need to add 2 new custom dimensions as shown below. Take note of the ID in case it differs from mine.

Screen Shot 2015-11-25 at 5.09.44 PM

Emojis

I may have been a little late to realize this, but I recently found out that you can pass emojis into Google Analytics and they’ll show up in your reports.

First, we’ll want to parse out the emoji from the message. In this case, we’ll just grab the first emoji and pass it into a custom dimension. Emojis appear within two colons, so we’ll want to grab it from in between them. Once we do that, we’ll want to match the emoji text with the actual emoji icon using a switch statement. Now, I honestly don’t have the patience to match every emoji, so I’ve done a couple handfuls for you. Let me know if you finish off the rest, and i’ll personally tweet you your favorite emoji.😃

Screen Shot 2015-11-25 at 5.01.52 PM

Next, add the emoji as a custom dimension to our data variable. Make sure the cd# matches the custom dimension ID created in the first step.

Screen Shot 2015-11-25 at 5.14.24 PM

@Mentions

Grabbing an @mention is very similar to the URL from my previous post. The username for all @mentions is placed in between <@USERNAME>, so we’ll use the following JavaScript to take care of that.

Screen Shot 2015-11-25 at 5.20.15 PM

Then just like we did for emojis, we’ll add it to our data variable so it gets added to our hit.

Screen Shot 2015-11-25 at 5.21.53 PM

 

And that’s it! Go ahead and add these dimensions to your custom report whichever way you like. Now you’ll be able to understand which emojis are popular amongst users and which users are mentioned the most.

You can download the full code here.

Let me know if there are any other creative ways you’ve been able to use this app.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.