How we built our Tweets app
September 21st, 2020
We recently launched Apps, and with it, our first app “Tweets”. It lists all the tweets about your websites, and lets you jump right into the conversation. In this blog post, we’ll explain how we built it, and by doing so, ate our own dog food!
The tweets look like this, and even display how many retweets and likes it has, as well as how many people have clicked the link within! 😁
What you’ll need
- Your Symmetrics account: Create an account for free over here.
- One Twitter project and app: Apply for a Twitter Developer Account to create those.
Pro-tip: You can also use our client package on npm to connect to our APIs.
Head over to the Symmetrics Keys page and create an Authentication Key. While there, also take note of your Symmetrics user ID. You’ll need both to interface our APIs. From Twitter, we’ll need the Bearer authentication token.
Kicking off our project, we’ll define these as variables first:
Unfortunately, we’re unable to search Twitter for
t.co/ links directly. We’ll need to compile a list of hostnames to search for to avoid having to input them manually. JsonQl to the rescue!
Our JsonQl query also removes any localhost hostnames from the list.
Searching Twitter for your website
Using the Twitter recent search endpoint, looking up your hostnames, now that we know them, is pretty straight forward!
Refer to the Twitter API documentation for information on how to extract more data from each tweet.
Putting it all together
Now that we’ve got both functions ready, we’ll use both in a simple utility function that creates a Twitter search query from the hostnames.
To retrieve page views and unique visits from each tweet, we use JsonQl to isolate referrals from
t.co/. From there, we can iterate over the tweets and check if the URL is present in the text, and apply respective metrics to each. And that’s pretty much it!
You can try any of the queries in the query console, or copy them to your own dashboard. Also, check out the CodePen for the complete, functional example. Not a Symmetrics user yet? Sign up now for a free 7-day-trial!
We will continue writing educational blog posts much like this one. Let us know if you’ve got feedback or ideas for our next post. See you around! ✌️