Custom Configuration
Overview
The configuration system is arguably the most important element built into GA4Dataform. With a proper configuration, you can manage variables, modularize features, and control your data transformation pipeline without modifying core SQLX files. Think of the configuration as a control panel of JavaScript variables that determine what the final SQL output will look like.
You can customize elements such as:
- Start date for data processing
- User properties to extract
- Event and item parameters to unnest
- Events to filter out
- URL parameters to capture
- User stitching 💎
- Session totals 💎
- Session-level custom parameters 💎
- Support for
freshandintradaytables 💎 - ... and many more!
This approach enables distribution of the same Dataform repository without hardcoded variables, making your implementation portable and maintainable.
Configuration Architecture
GA4Dataform uses a dual-configuration approach with two separate files:
Core Configuration
found in includes/core/default_config.js
- Contains default settings for standard event parameters and click IDs
- Provides fallback variables to prevent compilation errors
- Subject to updates when new features are introduced
- Should not be modified by users
Custom Configuration
found in includes/custom/config.js
- Your customization layer
- Takes precedence over default configuration
- Safe from updates and overwrites
- Where all your specific settings should be defined
Configuration Merging
The two configuration objects are merged using a JavaScript spread operator that prioritizes your custom settings:
const getConfig = () => {
const { coreConfig } = require("./default_config");
const { customConfig } = require("../custom/config");
return { ...coreConfig, ...customConfig };
};
Your values in config.js will always take precedence over the defaults, ensuring your customizations are preserved during updates.
All configuration variables and detailed instructions on how to use them available at the configuration variable page!