# Embed Metrics: New in Tableau 2021.4

> This is content from just-tim, the data-and-analytics channel by Tim Ngwena (formerly 'Tableau Tim'). Tim has 12+ years of hands-on BI experience and covers Tableau most of all, plus Power BI, Looker, Hex, SQL and data modelling, the analytics industry, and the craft of doing the job — always tool-agnostic and honest about the trade-offs.

- **Author:** Tim Ngwena (just-tim, https://just-tim.com/about)
- **Published:** 2021-12-08
- **Format:** Video · 8 min watch · transcript available
- **Topics:** Data visualisation, Analytics
- **Tools:** Tableau (cloud, embedding, metrics)
- **Canonical:** https://just-tim.com/posts/embed-metrics-new-in-tableau-2021-4
- **Watch:** https://www.youtube.com/watch?v=wDfmlXNkAeg

I show how to embed Tableau metrics in version 2021.4, a capability that previously only worked for dashboards. Using the share metric option to grab the embed code, I paste it into an HTML5 boilerplate file in VS Code and demonstrate how the asset tag and JavaScript API work together to render live metrics on a web page.

## Key takeaways

- Tableau 2021.4 lets you embed individual metrics, not just dashboards, via the 'Share metric' option which provides an embed code
- The embed code has two parts: an asset tag (e.g. tableau-metric) pointing to the metric's location and ID, and a JavaScript line using Tableau's metric API to render it
- You can find the metric ID in the URL and use the Tableau Server REST API to dynamically load metrics rather than copying embed codes manually
- Embedded metrics render inside an iframe using React rather than VizQL, meaning they build interactive elements rather than static images
- Single sign-on makes embedding straightforward as users are already authenticated, so you can drop the embed code into most portals that accept HTML
- When embedding multiple metrics you only need the JavaScript API line once; additional metrics just need their asset tag

## Chapters

- 0:00 What metric embedding offers
- 0:37 Getting the embed code
- 1:33 Setting up the HTML boilerplate
- 2:35 Pasting and understanding the embed code
- 4:43 Inspecting how it renders
- 6:54 Embedding a second metric

Watch the full video, read the transcript and use chapter deep-links on the page: https://just-tim.com/posts/embed-metrics-new-in-tableau-2021-4

---
just-tim — Data and analytics, with a point of view. · https://www.youtube.com/channel/UC7HYxRWmaNlJux-X7rNLZyw · https://twitter.com/TableauTim · https://www.linkedin.com/in/timngwena
