# Gatsby (https://talivia.com/zh-CN/docs/installation-guides/gatsby)



使用 Gatsby 的服务端渲染钩子，让 Talivia 出现在每个生成页面中。




## 添加脚本 [#添加脚本]

创建或打开 `gatsby-ssr.js`，将 Talivia 脚本追加到 body 后置组件。

```jsx
import React from 'react';

export const onRenderBody = ({ setPostBodyComponents }) => {
  setPostBodyComponents([
    <script
      key="talivia"
      defer
      src="https://talivia.com/script.js"
      data-website-id="YOUR_WEBSITE_ID"
    />,
  ]);
};
```

请替换网站编号。

使用 Talivia“设置 → 数据追踪”中的编号。

构建或运行 Gatsby、打开页面，然后在 Talivia 中验证会话。
