Source: https://datafa.st/docs/google-tag-manager
Markdown source: https://datafa.st/docs/google-tag-manager.md
Description: How to add DataFast to your website using Google Tag Manager

# Implement DataFast with Google Tag Manager

Use Google Tag Manager (GTM) to easily deploy and manage DataFast analytics across your website without modifying code directly.

## Get started with Google Tag Manager

1. Log in to your [Google Tag Manager account](https://tagmanager.google.com/)
2. Select your container
3. Click on **Tags** > **New**
4. Name your tag (e.g., "DataFast Analytics")
5. Click **Tag Configuration** and select **Custom HTML**
6. Paste the following JavaScript code (not the regular script tag):

```html
<script>
  (function() {
    var script = document.createElement('script');
    script.defer = true;
    script.setAttribute('data-website-id', 'dfid_******');
    script.setAttribute('data-domain', 'your_domain.com');
    script.src = 'https://datafa.st/js/script.js';
    document.head.appendChild(script);
  })();
</script>
```

> Replace `dfid_******` and `your_domain.com` with your actual values from the DataFast dashboard.

7. Click **Triggering**, select **All Pages** and click **Add**
8. Click **Save** 
9. Click **Submit** at the top right, then **Publish**

## Troubleshooting

- If data doesn't appear, check that your tag is firing in GTM's preview mode
- Verify that your website ID and domain values are correct
- Ensure the tag isn't being blocked by content security policies (CSP)
- Make sure your tag is executing early in the page load sequence by setting it to fire at the earliest appropriate event

> For advanced configuration options like localhost tracking, custom API endpoints, or cross-domain setup, see the [script configuration reference](/docs/script-configuration).
