DataFast script configuration
DataFast tracking script supports several data attributes that allow you to customize tracking behavior. This guide covers all available configuration options.
New to DataFast? Start with the installation guide first.
Website ID data-website-id
(required)
Your unique website identifier from DataFast.
Example:
<script
defer
data-website-id="dfid_abc123def456" // 👈 ✅
data-domain="yourdomain.com"
src="https://datafa.st/js/script.js"
></script>
Domain data-domain
(required)
Your website's root domain. Used for cookie management across subdomains.
- Note: By default, DataFast will track all subdomains of your root domain. For instance, if your root domain is
example.com
, DataFast will work onapp.example.com
,blog.example.com
,shop.example.com
, etc.
See subdomain tracking documentation for tracking across subdomains.
Example:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com" // 👈 ✅
src="https://datafa.st/js/script.js"
></script>
Allowed Hostnames data-allowed-hostnames
(optional)
Comma-separated list of additional domains for cross-domain tracking. (comma-separated)
- Default: Empty (no cross-domain tracking)
- Example:
app.io,shop.example.com
- Use case: Track users across different root domains
Example:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
data-allowed-hostnames="app.io,myapp.org" // 👈 ✅
src="https://datafa.st/js/script.js"
></script>
See cross-domain tracking documentation for setup details.
API URL data-api-url
(optional)
Custom API endpoint for sending events. Provide a full URL or a relative path.
- Example:
https://api.example.com/events
or/custom-events
- Use case: Custom API endpoints, third-party analytics proxies, or advanced proxy configurations
If you use a relative path, it will be appended to your domain. For instance, if your domain is example.com
and you use /custom-events
, the full URL will be https://example.com/custom-events
.
Example with full URL:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
data-api-url="https://api.example.com/track" // 👈 ✅ Full URL
src="https://datafa.st/js/script.js"
></script>
Example with path:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
data-api-url="/custom-analytics-endpoint" // 👈 ✅ Relative path
src="https://datafa.st/js/script.js"
></script>
Note: DataFast automatically detects proxied setups. Only use this if you need a custom endpoint path or want to send events to a completely different server. If the provided URL is invalid, DataFast will fall back to the default endpoint. See proxy guides for detailed setup instructions.
Allow Localhost data-allow-localhost
(optional)
Enable tracking on localhost for development and testing.
("true"
or "false"
)
- Default:
false
- Example:
data-allow-localhost="true"
- Use case: Testing analytics implementation locally
Example:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
data-allow-localhost="true" // 👈 ✅
src="https://datafa.st/js/script.js"
></script>
Tracking is disabled on localhost by default to prevent polluting your production analytics data. See excluding visits for other ways to exclude traffic.
Allow File Protocol data-allow-file-protocol
(optional)
Enable tracking when opening HTML files directly in browser (file:// protocol).
("true"
or "false"
)
- Default:
false
- Example:
data-allow-file-protocol="true"
- Use case: Testing with local HTML files
Example:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
data-allow-file-protocol="true" // 👈 ✅
src="https://datafa.st/js/script.js"
></script>
Debug Mode data-debug
(optional)
Enable debug mode to allow tracking inside iframes.
("true"
or "false"
)
- Default:
false
- Example:
data-debug="true"
- Use case: Testing tracking in embedded contexts
Example:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
data-debug="true" // 👈 ✅
src="https://datafa.st/js/script.js"
></script>
By default, DataFast doesn't track inside iframes to prevent duplicate tracking.
Disable Console data-disable-console
(optional)
Disable all console logging from DataFast tracker.
("true"
or "false"
)
- Default:
false
- Example:
data-disable-console="true"
- Use case: Clean console logs in production
Example:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
data-disable-console="true" // 👈 ✅
src="https://datafa.st/js/script.js"
></script>
HTML element attributes
These attributes are added to HTML elements in your page to enable automatic tracking.
Goal Tracking data-fast-goal
(optional)
Track clicks on any element as a custom goal. (goal name)
- Rules: Lowercase letters, numbers, underscores, hyphens only. Max 32 characters.
- Example:
checkout_initiated
- Use case: Track button clicks, link clicks, or any user interaction
Example:
<button data-fast-goal="add_to_cart">Add to Cart</button> // 👈 ✅
See custom goals documentation for more examples.
Goal Parameters data-fast-goal-*
(optional)
Add custom parameters to goal events. The parameter name is extracted from the attribute name. (parameter value)
- Naming:
data-fast-goal-{parameter-name}
(kebab-case, converted to snake_case) - Rules: Max 10 parameters per event. Parameter names: lowercase, numbers, underscores, hyphens, max 32 chars. Values: max 255 chars.
- Example:
data-fast-goal-product-id="prod_123"
Example:
<button
data-fast-goal="product_added"
data-fast-goal-product-id="prod_123" // 👈 ✅
data-fast-goal-product-name="Premium Plan" // 👈 ✅
data-fast-goal-price="49"> // 👈 ✅
Add to Cart
</button>
In this example, DataFast tracks a goal named product_added
with parameters:
{
product_id: "prod_123",
product_name: "Premium Plan",
price: "49"
}
Scroll Tracking data-fast-scroll
(optional)
Automatically track when element becomes visible during scrolling. (goal name)
- Default trigger: Element is 50% visible
- Rules: Same as
data-fast-goal
(lowercase, numbers, underscores, hyphens, max 32 chars) - Example:
scroll_to_pricing
Example:
<section data-fast-scroll="viewed_pricing"> // 👈 ✅
<h2>Pricing</h2>
<!-- Pricing content -->
</section>
See scroll tracking documentation for detailed examples.
Scroll Threshold data-fast-scroll-threshold
(optional)
Customize visibility threshold for scroll tracking.
- Type: Number (decimal between 0 and 1)
- Default:
0.5
(50% of element visible) - Example:
0.8
(80% visible) - Use case: Fine-tune when tracking triggers based on element visibility
Example:
<section
data-fast-scroll="viewed_hero"
data-fast-scroll-threshold="0.8"> // 👈 ✅
<!-- Tracks when 80% of this section is visible -->
</section>
Common threshold values:
0.1
- Track as soon as element appears (10% visible)0.5
- Track when half visible (default)0.9
- Track when almost fully visible (90% visible)1.0
- Track only when completely visible
Scroll Delay data-fast-scroll-delay
(optional)
Add delay before tracking scroll event.
- Type: Number (milliseconds)
- Default:
0
(no delay) - Example:
2000
(2 seconds) - Use case: Ensure users spend time viewing content before tracking
Example:
<section
data-fast-scroll="read_testimonials"
data-fast-scroll-threshold="0.7" // 👈 ✅
data-fast-scroll-delay="3000">
<!-- Tracks only if element stays visible for 3 seconds -->
</section>
Scroll Parameters data-fast-scroll-*
Add custom parameters to scroll tracking events, similar to data-fast-goal-*
.
(parameter value)
- Naming:
data-fast-scroll-{parameter-name}
(kebab-case, converted to snake_case) - Example:
data-fast-scroll-section-name="hero"
Example:
<section
data-fast-scroll="section_viewed"
data-fast-scroll-section-name="testimonials" // 👈 ✅
data-fast-scroll-section-order="3">
<!-- Custom parameters help analyze which sections engage users -->
</section>
Common configuration examples
Development environment
Enable tracking on localhost for testing:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
data-allow-localhost="true" // 👈 ✅
src="https://datafa.st/js/script.js"
></script>
Production with proxy
Proxy script through your domain to bypass ad blockers:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
src="/js/script.js" // 👈 ✅
></script>
DataFast auto-detects proxied setup. No data-api-url
needed if you proxy both /js/script.js
and /api/events
. See proxy setup guide for implementation details.
Cross-domain tracking (optional)
Track users across multiple domains:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
data-allowed-hostnames="app.io,shop.example.net" // 👈 ✅
src="https://datafa.st/js/script.js"
></script>
Use the same configuration on all tracked domains.
Clean production setup
Minimal console output in production:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
data-disable-console="true" // 👈 ✅
src="https://datafa.st/js/script.js"
></script>
Hash-based navigation tracking
For Single Page Applications with hash routing (e.g., #home
, #about
), use the hash-enabled script:
<script
defer
data-website-id="dfid_abc123def456"
data-domain="example.com"
src="https://datafa.st/js/script.hash.js" // 👈 ✅
></script>
See hashed page paths documentation for more details on tracking hash-based navigation.
Validation rules summary
Goal and event names
- Characters: Lowercase letters, numbers, underscores (_), hyphens (-)
- Length: Maximum 32 characters
- Examples:
checkout_started
,newsletter-signup
,add_to_cart
Custom parameter names
- Characters: Lowercase letters, numbers, underscores (_), hyphens (-)
- Length: Maximum 32 characters
- Conversion: kebab-case attributes automatically converted to snake_case
- Example:
data-fast-goal-product-id
→product_id
Custom parameter values (any characters)
- Length: Maximum 255 characters
- HTML/XSS: Dangerous characters automatically sanitized
- Limit: Maximum 10 custom parameters per event
Scroll threshold
- Type: Decimal number
- Range: 0.0 to 1.0
- Default: 0.5
- Examples:
0.1
(10%),0.75
(75%),1.0
(100%)
Scroll delay
- Type: Integer (milliseconds)
- Range: 0 or greater
- Default: 0 (no delay)
- Examples:
1000
(1 second),5000
(5 seconds)
Troubleshooting
Tracking not working on localhost
Make sure you've added data-allow-localhost="true"
to enable local tracking:
<script data-allow-localhost="true" ... ></script> // 👈 ✅
For excluding your own visits on production, see excluding visits documentation.
Custom goals not firing
Check your goal name follows validation rules:
- Lowercase only
- No spaces or special characters (except _ and -)
- Max 32 characters
Cross-domain tracking not working
Verify:
- Same
data-website-id
on all domains - All additional domains listed in
data-allowed-hostnames
- Users click links between domains (tracking params appended to URLs)
Scroll tracking not triggering
Common issues:
- Element not in viewport long enough
- Threshold set too high (try lowering from 1.0 to 0.5)
- IntersectionObserver not supported (check browser compatibility)
See scroll tracking documentation for detailed troubleshooting and examples.
Related documentation
- Getting started guide - Initial setup and installation
- Custom goals - Track user actions and events
- Scroll tracking - Track element visibility and engagement
- Conversion funnels - Analyze multi-step user journeys
- Cross-domain tracking - Track users across different domains
- Subdomain tracking - Track users across subdomains
- Proxy setup guides - Bypass ad blockers with proxying
- Excluding visits - Exclude specific traffic from analytics
- User identification - Track users across devices and sessions
- Revenue attribution - Connect payments to marketing channels
Need more help? Contact us at marc@datafa.st