Can I embed tweets in emails? No, because of JavaScript and iframes

A tweet is an individual message posted by someone inside the twitter social media platform. An embeddable tweet is a version of this message that can be copied and used outside twitter. Embedding tweets is a great feature, allowing conversations and ideas to be spread beyond twitter’s walls, and is great for curation and analysis.

But the way that twitter have constructed this feature means that you can’t embed tweets in emails.

Why is this? You can’t display embedded tweets in emails because embedded tweets require:

  1. JavaScript
  2. iframes

Both of these features are blocked by most email clients for very sensible security reasons.

So an embedded tweet that should look something like this:

… ends up looking like this instead:

#ed473 this is really thought-provoking. @anildash on gender privilege & social networks: The Year I Didn't RT Men. https://t.co/qZXGCdv545

— Bonnie Stewart (@bonstewart) February 13, 2014

This isn’t nearly as useful or pretty.

So what can I do instead if I want to embed a tweet in an email?

Lots of people simply share tweets by taking a screenshot of the message, and then pasting it to wherever is needed – eg into a powerpoint presentation.
This solution could work in the context of sending an email: take a screenshot of the tweet you’re interested in, trim to size, upload somewhere, and add in to your email. For extra credit, make the image a hyperlink to the original tweet.

This solution isn’t ideal – it’s manual, laborious, and cannot be easily automated. The information about the tweet will become outdated as more people share or retweet it, or reply to it. Worse, it’s not possible to actually interact with the tweet in this setting, nor is this option at all accessible (unless you are very diligent with your alt text).

Okay then, come up with something smarter

I haven’t created anything better, I’m afraid, but here’s one idea to investigate:

If our aim is to take the useful features of embedded tweets – aesthetics and functionality – and to get them into email, I think that Twitter’s “Do you know…” emails could help:

a screenshot of an automated email from twitter suggesting some accounts I might want to follow

You could take the inline HTML from these emails (I’ve copied the HTML code here) and use them to style up embedded tweets in an HTML email. You’d need to check in with twitter’s brand policies though, as this may not be within their terms of use.

  • martinlugton

    NB I think the javascript works on class, so I had to remove ‘class=”twitter-tweet”‘ from the example of a non-functional embedded tweet. Otherwise the javascript running from the above tweet would catch it.

  • monng

    I have found a way to add a twitter feed/wall on any site that dont support javascript/jquery the site i used is feed-generator com and i think this is the best solution right now.

  • martinlugton

    A neat example that presents a scrolling timeline. It doesn’t use a twitter embed – and so doesn’t use Javascript or iframes. The stream isn’t real-time, but it’s still an impressive idea and implementation https://litmus.com/blog/how-to-code-a-live-dynamic-twitter-feed-in-html-email

  • Brad Vogel

    Mixmax for Gmail allows you to embed a live Twitter feed in your email. It works in all email clients and is refreshed each time your recipient opens your email. It uses an iframe (on clients that support it) with a dynamic image fallback. Check out https://mixmax.com/blog/embed-your-twitter-directly-in-your-email

    • martinlugton

      Thanks for sharing, Brad. I guess that as iframe support is so limited, in practice this will mostly use the dynamic image fallback, but that’s a neat solution 🙂

  • Paul

    WidgMail will allow marketers to add tweets to their emails that live update each time an email is read. You can embed for a specific @user or #hashtag. Pretty cool service: https://www.widgmail.com/