---
schema_version: "1"
id: a60cce892b3d1807d05ecdce577994706020371553cb0cc75cd2c1883cc9e270
title: 將指標內嵌至網頁（已淘汰）
collection: tableau
version: current
locale: zh-tw
portal_url: https://docs.salesforce.com/tableau/current/zh-tw/pro/desktop/embed_metrics.md
canonical_url: https://help.tableau.com/current/pro/desktop/zh-tw/embed_metrics.htm
source_site: help.tableau.com
content_type: documentation
content_hash: 9860da03423497f665c70368c0e6daf8bab9b505528f3a9ac5feb1f3c46594d2
description: Embed legacy metrics into webpages. This retired feature was replaced by Tableau Pulse.
---
[跳至主要內容](#main-content)

# 將指標內嵌至網頁（已淘汰）

**淘汰舊版指標功能**

Tableau 的舊版指標功能於 2024 年 2 月在 Tableau Cloud 和 Tableau Server 版本 2024.2 中已淘汰。2023 年 10 月，Tableau 已淘汰在 Tableau Cloud 和 Tableau Server 版本 2023.3 中內嵌舊版指標的功能。借助 Tableau Pulse，我們開發了一種改進的體驗來追蹤指標和對資料提出問題。有關詳細資訊，請參閱[使用 Tableau Pulse 建立指標](https://help.tableau.com/current/online/zh-tw/pulse_create_metrics.htm)以瞭解新的體驗，以及[建立指標並進行疑難排解（已淘汰）](https://help.tableau.com/current/online/zh-tw/metrics_create.htm)以瞭解此淘汰的功能。

您可以內嵌指標以將它們與其他 Web 內容一起顯示在與您的 Viewer 最相關的上下文中。載入內嵌指標時，會直接連線到 Tableau Server 或 Tableau Cloud 的資料，因此可獲得最新的可用資料。

要將指標內嵌網頁，請複製 Tableau Server 或 Tableau Cloud 上提供的 HTML 內嵌程式碼，或使用下面顯示的 JavaScript 範例。只要這些指標來自同一個 Tableau 站台，就可以在單個頁面上內嵌多個指標。

內嵌指標可與 Tableau Cloud 或 Tableau Server 支援的相同 Web 瀏覽器一起使用。有關支援的瀏覽器清單，請參閱[技術規格](https://www.tableau.com/zh-tw/products/techspecs)。儘管 Safari 支援內嵌，但 Viewer 必須關閉「防止跨站台追蹤」才能看到內嵌的內容。

內嵌指標的內嵌程式碼和參數與用於內嵌檢視的程式碼和參數不同。有關如何內嵌檢視的詳情，請參閱[將檢視內嵌網頁](https://help.tableau.com/current/pro/desktop/zh-tw/embed.htm)。

**附註：**Tableau 管理員可以限制允許嵌入或完全停用嵌入的站台。如果未載入您的嵌入指標未，請與管理員聯繫，以確保嵌入其站台在嵌入允許清單中。更多資訊請參閱[用於內嵌的 Tableau 站台設定](https://help.tableau.com/current/api/embedding_api/zh-tw/docs/embedding_api_site.html)。

## 複製內嵌程式碼

內嵌指標的最快方法是複製 Tableau 提供的內嵌程式碼。

1. 在 Tableau Cloud 或 Tableau Server 上，巡覽到要內嵌的指標詳細資訊頁面。
2. 按一下「共用指標」按鈕。
3. 按一下「複製內嵌程式碼」。  
    ![在共用對話方塊上複製內嵌程式碼紐按鈕](/tableau/current/zh-tw/pro/desktop/zh-tw/Img/share_embed_code_metrics.png)
4. 將內嵌程式碼貼上要內嵌指標的網頁中。

## 編寫自己的內嵌程式碼

當從 Tableau Server 或 Tableau Cloud 複製內嵌程式碼時，複製的會是 HTML 內嵌程式碼，沒有任何可選參數。如果想更好控制內嵌指標，可以自訂 HTML 或使用 JavaScript 範例編寫自己的指令碼。

### HTML 範例

```
<tableau-metric
	src='https://mycompany/#/metrics/1'
	link-target='https://example.com'>
</tableau-metric>
<script type='module' src='https://mycompany/javascripts/api/tableau.metric.1.latest.min.js'></script>
```

### JavaScript 範例

```
<div id='metricDiv'/>
<script type='module'>
	import { TableauMetric } from 'https://mycompany/javascripts/api/tableau.metric.1.latest.min.js';
				
	let metric = new TableauMetric();

	metric.src = 'https://mycompany/#/metrics/1';
	metric.linkTarget = 'https://example.com';document.getElementById('metricDiv').appendChild(metric);
</script>
```

## 內嵌程式碼的參數

內嵌程式碼的參數可用於自訂 HTML 和 JavaScript 內嵌選項。

<table class="table--plain"><thead><tr><th>參數</th><th>值</th><th>描述</th><th>範例</th></tr></thead><tbody><tr><td>src<br>（必需）</td><td>字串</td><td>在 Tableau Server 或 Tableau Cloud 中指標的 URL。</td><td><code>https://mycompany/#/metrics/1</code></td></tr><tr><td><p>連結目標 (HTML)</p><p>連結目標 (JavaScript)<br></p><p>（可選）</p></td><td>字串</td><td>Viewer 按一下該指標將被導向到的 URL。如果未指定目標，則內嵌指標將連結到來源 URL。</td><td><code>http://example.com</code></td></tr></tbody></table>

## 內嵌指標的身份驗證

內嵌指標遵守 Tableau Server 和 Tableau Cloud 上使用的相同授權和權限限制。要查看內嵌指標，Viewer 必須登入內嵌該指標的 Tableau 站台上的帳戶。與內嵌檢視不同，內嵌指標不允許使用訪客帳戶向未登入的 viewer 顯示指標。

如果未在另一個索引標籤中登入 Tableau Server 或 Tableau Cloud，會為 Viewer 提示須從內嵌指標本身登入。要從內嵌指標成功登入，必須將 Viewer 的瀏覽器配置為允許第三方 cookie。

內嵌指標支援 Tableau Server 和 Tableau Cloud 的所有身份驗證方法，受信任身份驗證除外。對於從 Tableau Server 內嵌的指標，伺服器必須使用 HTTPS 來保護通訊。

要為內嵌指標啟用單一登入體驗，您的 Tableau 管理員必須在 Tableau Server 與外部授權伺服器（僅限 Tableau Server）或與 Tableau 連線的應用程式和網頁之間配置信任關係。有關詳細資訊，請參見 Tableau Server 說明中的[註冊 EAS 以啟用內嵌內容的 SSO](https://help.tableau.com/current/server-linux/zh-tw/connected_apps_eas.htm) 或 Tableau Cloud 說明中的[設定 Tableau 連線的應用程式以啟用內嵌內容的 SSO](https://help.tableau.com/current/online/zh-tw/connected_apps.htm)。

## 如何組建指標 URL

要內嵌指標，請指定指標 URL 和用於呈現指標的 JavaScript 的 URL。指標 URL 在 Tableau Cloud、具有單一站台的 Tableau Server 環境和多站台 Tableau Server 環境中遵循略有不同的模式。如果不確定如何設定 URL 格式，請複製內嵌程式碼，因為它同時包含指標 URL 和 JavaScript URL。

指標必須託管於 Tableau Server 或 Tableau Cloud 上。不能從本機檔案內嵌指標。

### 指標 URL 結構

- Tableau Cloud 站台：`https://<pod>.online.tableau.com/#/site/<sitename>/metrics/<metric>`
- Tableau Server 單個站台（或預設站台）：`https://<servername>/#/metrics/<metric>`
- Tableau Server 多站台：`https://<servername>/#/site/<sitename>/metrics/<metric>`

### JavaScript URL 結構

指標 URL 會根據內嵌的站台而變化，但呈現指標的 JavaScript 的 URL 不會變更，因為它不包含該站台。

- Tableau Cloud 站台：`https://<pod>.online.tableau.com/javascripts/api/tableau.metric.1.latest.min.js`
- Tableau Server：`https://<servername>/javascripts/api/tableau.metric.1.latest.min.js`