A comprehensive collection of pre-configured tag templates for analytics, marketing, and tracking services on Fynd Platform storefronts.
// Import all templates
const templates = require('@gofynd/storefront-tag-templates');
// Use a specific template
const gtmTemplate = templates.gtm;
const sentryTemplate = templates.sentry;// Import specific templates
const { gtm, ga4, hotjar } = require('@gofynd/storefront-tag-templates');To reduce bundle size, you can import only the category of templates you need:
// Import only analytics templates
const analyticsTemplates = require('@gofynd/storefront-tag-templates/analytics');
// Access: gtm, ga4, amplitude, adobeAnalytics, mixpanel, heap, etc.
// Import only session recording templates
const recordingTemplates = require('@gofynd/storefront-tag-templates/recording');
// Access: hotjar, crazyegg, fullstory, mouseflow, logrocket
// Import only customer engagement templates
const engagementTemplates = require('@gofynd/storefront-tag-templates/engagement');
// Access: clevertap, moengage, webengage, pushengage, notifyvisitors, intercom
// Import only A/B testing templates
const testingTemplates = require('@gofynd/storefront-tag-templates/testing');
// Access: optimizely, adobeTarget, abTasty
// Import only feedback/survey templates
const feedbackTemplates = require('@gofynd/storefront-tag-templates/feedback');
// Access: qualaroo, survicate, typeform, usabilla
// Import only error monitoring templates
const monitoringTemplates = require('@gofynd/storefront-tag-templates/monitoring');
// Access: sentry, trackjs// Import all templates
import templates from '@gofynd/storefront-tag-templates';
// Import specific categories for smaller bundle size
import analyticsTemplates from '@gofynd/storefront-tag-templates/analytics';
import recordingTemplates from '@gofynd/storefront-tag-templates/recording';const { createTemplate } = require('@gofynd/storefront-tag-templates');
const myCustomTemplate = createTemplate({
name: 'My Custom Tag',
template_id: '2001',
// ... other configuration
});- Google Tag Manager (
gtm) - Container-based tag management - Google Analytics 4 (
ga4) - Google's latest analytics platform - Amplitude (
amplitude) - Product analytics for user behavior - Adobe Analytics (
adobeAnalytics) - Enterprise analytics solution - Mixpanel (
mixpanel) - Product analytics with user tracking - Heap (
heap) - Automatic event tracking analytics - Adobe Launch (
adobeLaunch) - Adobe's tag management system - Segment (
segment) - Customer data platform - mParticle (
mparticle) - Customer data platform - Quantcast (
quantcast) - Audience measurement
- Hotjar (
hotjar) - Heatmaps and session recordings - Crazy Egg (
crazyegg) - Heatmaps and A/B testing - FullStory (
fullstory) - Digital experience analytics - Mouseflow (
mouseflow) - Session replay and heatmaps - LogRocket (
logrocket) - Session replay with console logs
- Optimizely (
optimizely) - Experimentation platform - Adobe Target (
adobeTarget) - Personalization and testing - AB Tasty (
abTasty) - A/B testing and personalization
- CleverTap (
clevertap) - Customer engagement platform - MoEngage (
moengage) - Customer engagement automation - WebEngage (
webengage) - Marketing automation - PushEngage (
pushengage) - Web push notifications - NotifyVisitors (
notifyvisitors) - Customer engagement tools - Intercom (
intercom) - Customer messaging platform
- Qualaroo (
qualaroo) - User research and feedback - Survicate (
survicate) - Customer feedback surveys - Typeform (
typeform) - Interactive forms and surveys - Usabilla (
usabilla) - User feedback management
- Sentry (
sentry) - Error tracking and monitoring - TrackJS (
trackjs) - JavaScript error monitoring - Totango (
totango) - Customer success platform
Every template is a JavaScript object with specific keys that define its behavior and configuration. Here's a complete guide to creating your own template.
These keys MUST be present in every template:
The display name of your template shown in the UI.
name: "Google Analytics 4"Unique URL-friendly identifier for the template.
path: "google-analytics-4"Brief description of what the template does.
description: "Track user behavior and measure site performance with Google Analytics."Unique numeric identifier for the template.
template_id: "2001"Version number of the template following semantic versioning.
template_version: "1.0.0"Array of form field configurations that users will fill out. See Field Configuration for details.
fields: [
{
name: "apiKey",
type: "text",
label: "API Key",
required: true
}
]The JavaScript code template that will be injected into the page. Use {{fieldName}} placeholders for dynamic values.
script: `(function() {
var apiKey = '{{apiKey}}';
// Your tracking code here
})();`Categorizes the template for better organization. Common categories:
analytics- Analytics and measurement toolsrecording- Session recording and heatmapstesting- A/B testing and experimentationengagement- Customer engagement and messagingfeedback- Surveys and feedback collectionmonitoring- Error tracking and monitoringperformance- Performance monitoring
category: 'analytics'URL to the service's logo image.
img: "https://logo.clearbit.com/google.com"Help text shown to users. Supports markdown for bold text.
note: "Find your **API Key** in Settings → API Keys. This key is required for tracking."Link to external documentation.
help_link: {
text: "Learn more about setup in the",
url: "https://docs.example.com/setup",
label: "Documentation"
}Script type. Default: 'js'
type: 'js'Script loading method. Options: 'inline' (default) or 'external'
sub_type: 'inline'Where to inject the script. Options: 'head' (default) or 'body'
position: 'head'Specific pages to include the script. Default: ['all']
pages: ['home', 'product', 'checkout']Pages to exclude from script injection.
excludePages: ['admin', 'login']HTML attributes to add to the script tag.
attributes: {
async: "true",
defer: "true",
"data-domain": "example.com"
}Template engines this tag works with.
compatible_engines: ['react', 'vue2']Maps template field names to storage keys.
field_mappings: {
apiKey: 'analytics_api_key',
userId: 'user_identifier'
}Form layout configuration.
layout: {
columns: 2, // Number of columns (1, 2, or 3)
gap: '24px', // Gap between fields
responsive: true // Enable responsive behavior
}Custom logic to control save button state.
saveButtonDisabled: function(formData, errors, component) {
// Return true to disable, false to enable
return formData.apiKey && formData.apiKey.length < 10;
}Fields define the form inputs users interact with. Each field is an object with these properties:
{
name: "apiKey", // Field identifier (required)
type: "text", // Field type (required)
label: "API Key", // Display label (required)
required: true, // Is field required?
size: "medium", // Field size: small, medium, large, full
placeholder: "Enter key", // Placeholder text
description: "Your API key", // Help text below field
default: "default-value" // Default value
}- text - Single line text input
{
name: "apiKey",
type: "text",
label: "API Key",
validation: {
pattern: /^[A-Z0-9]+$/,
message: "Only uppercase letters and numbers allowed"
}
}- textarea - Multi-line text input
{
name: "customCode",
type: "textarea",
label: "Custom JavaScript",
rows: 5 // Number of visible rows
}- number - Numeric input
{
name: "timeout",
type: "number",
label: "Timeout (ms)",
validation: {
min: 100,
max: 10000,
message: "Must be between 100 and 10000"
}
}- select - Dropdown selection
{
name: "region",
type: "select",
label: "Data Region",
options: [
{ label: "United States", value: "us" },
{ label: "Europe", value: "eu" },
{ label: "Asia Pacific", value: "apac" }
],
default: "us",
searchable: true // Enable search in dropdown
}- checkbox - Boolean toggle
{
name: "enableTracking",
type: "checkbox",
label: "Enable Tracking",
default: true
}- array - Dynamic list of values
{
name: "allowedDomains",
type: "array",
label: "Allowed Domains",
default: [],
input_config: {
type: "text",
placeholder: "example.com",
button_text: "Add Domain",
input_size: "medium",
button_size: "small",
validation: {
pattern: /^[a-z0-9.-]+\.[a-z]{2,}$/i,
message: "Must be a valid domain"
}
}
}- Conditional Fields - Show/hide based on other fields
{
name: "apiSecret",
type: "text",
label: "API Secret",
condition: function(formData) {
return formData.authType === 'oauth';
}
}- Field Events - React to user interactions
{
name: "websiteUrl",
type: "text",
label: "Website URL",
events: {
blur: function(value, field, formData, component) {
// Clean up URL on blur
if (value && !value.startsWith('http')) {
component.$set(formData, field.name, 'https://' + value);
}
},
change: function(value, field, formData, component) {
// React to changes
console.log('URL changed to:', value);
}
}
}- Validation - Client-side validation
{
name: "email",
type: "text",
label: "Email",
validation: {
pattern: /^[^\s@]+@[^\s@]+\.[^\s@]+$/,
message: "Please enter a valid email address"
}
}- Help Links - Additional documentation
{
name: "complexField",
type: "text",
label: "Complex Configuration",
help_link: {
url: "https://docs.example.com/complex-field",
text: "Learn more"
}
}touch src/templates/myservice.jsconst createTemplate = require('../utils/createTemplate');const myServiceTemplate = createTemplate({
// Required fields
name: "My Service",
path: "my-service",
description: "Description of what My Service does",
template_id: "2001",
template_version: "1.0.0",
// Categorization
category: 'analytics',
// Visual elements
img: "https://logo.clearbit.com/myservice.com",
note: "Find your **Account ID** in Settings → Account.",
help_link: {
text: "Learn more in the",
url: "https://docs.myservice.com",
label: "Documentation"
},
// Technical configuration
type: 'js',
sub_type: 'inline',
position: 'head',
attributes: {
async: "true"
},
compatible_engines: ['react', 'vue2'],
// Field mappings
field_mappings: {
accountId: 'my_service_account_id'
},
// Layout
layout: {
columns: 2,
gap: '24px'
},
// Form fields
fields: [
{
name: "accountId",
type: "text",
label: "Account ID",
placeholder: "YOUR_ACCOUNT_ID",
required: true,
size: "full",
description: "Find in Settings → Account",
validation: {
pattern: /^[A-Z0-9]{8,}$/,
message: "Must be at least 8 characters"
}
},
{
name: "enableTracking",
type: "checkbox",
label: "Enable Tracking",
default: true,
size: "medium",
description: "Track page views automatically"
}
],
// Script template
script: `(function() {
var accountId = '{{accountId}}';
var enableTracking = {{enableTracking}};
// Your tracking code here
var script = document.createElement('script');
script.src = 'https://cdn.myservice.com/tracker.js?id=' + accountId;
script.async = true;
if (enableTracking) {
script.onload = function() {
window.MyService.init(accountId);
window.MyService.trackPageView();
};
}
document.head.appendChild(script);
})();`
});
module.exports = myServiceTemplate;Edit src/template.js:
// Import your template
const myServiceTemplate = require('./templates/myservice');
// Add to the templates object in the appropriate category
const templates = {
// Analytics
gtm: gtmTemplate,
ga4: ga4Template,
myservice: myServiceTemplate, // Add your template here
// ... other templates
};Edit src/index.js:
// Add individual export
module.exports.myservice = templates.myservice;npm run build
npm test- Use meaningful template IDs - Start from 2000+ for custom templates
- Validate user inputs - Add proper validation patterns
- Provide helpful descriptions - Make fields self-explanatory
- Use conditional fields - Show only relevant options
- Handle errors gracefully - Add try-catch blocks in scripts
- Document special requirements - Use the note field effectively
- Test thoroughly - Verify the generated script works correctly
- Use IIFE - Wrap scripts in immediately invoked function expressions
script: `(function() {
// Your code here
})();`- Handle boolean values correctly
var isEnabled = {{enableFeature}}; // Will output: true/false
if (isEnabled) { /* ... */ }- Handle arrays
var domains = [{{allowedDomains}}]; // Will output: ["domain1.com", "domain2.com"]-
Escape special characters - The template system handles this automatically
-
Check for required dependencies
if (typeof window.jQuery === 'undefined') {
console.error('jQuery is required');
return;
}- Fork the repository
- Create your feature branch (
git checkout -b feature/new-template) - Add your template following the guide above
- Add tests for your template
- Commit your changes (
git commit -am 'Add new template') - Push to the branch (
git push origin feature/new-template) - Create a Pull Request
MIT © Fynd Platform
For more information, visit the GitHub repository.