We do not store or save any of the data you input!
Are you looking to streamline your e-commerce tracking and marketing efforts? We’re excited to introduce our Free E-commerce Google Tag Manager (GTM) Container Generator—a tool designed to simplify the process of setting up GTM containers for your e-commerce website. This tool allows you to generate a customized GTM container JSON file by simply inputting your Google Analytics 4 (GA4) Measurement ID and Google Ads Conversion ID.
In this blog post, we’ll walk you through:
- What the tool does
- What it outputs
- How to structure your Data Layer objects to work seamlessly with this tool
What Does This GTM Container Generator Tool Do?
Our GTM Container Generator is designed to automate the creation of a GTM container tailored to your e-commerce tracking needs. Here’s what it accomplishes:
- User-Friendly Input: Provides a simple form where you can enter your GA4 Measurement ID and Google Ads Conversion ID.
- Customized GTM Container: Generates a GTM container JSON file that includes tags, triggers, and variables configured with your specific IDs and all the necessary settings to effectively track GA4 enhanced ecommerce.
- Downloadable Output: Allows you to download the customized JSON file, which you can then import directly into your GTM account.
By automating this process, you save time and reduce the likelihood of errors that can occur when manually setting up GTM containers.
What Does Our Tool Output?
The tool outputs a customized GTM container JSON file that includes:
- GA4 Configuration Tag: Set up with your GA4 Measurement ID to track page views and other events.
- GA4 Event Tags: Configured for all enhanced e-commerce events like
purchase
,add_to_cart
, andview_item
. - Google Ads Remarketing Tag: Configured with your Google Ads Conversion ID for remarketing purposes.
- Triggers: Custom triggers for e-commerce events based on your datalayer.
- Variables: Pre-defined variables to pull data from your Data Layer, such as product details, coupons, and transaction information.
Sample Output Structure
Here’s a simplified version of what the output JSON file contains:
{
"containerVersion": {
"container": {
"name": "E-commerce GTM Container"
},
"tag": [
{
"name": "GA4 - Config",
"type": "googtag",
"parameter": [
{
"key": "tagId",
"value": "{{ga4 measurement id}}"
}
],
"firingTriggerId": ["All Pages"]
},
{
"name": "GA4 - Event - Purchase",
"type": "gaawe",
"parameter": [
{
"key": "eventName",
"value": "purchase"
}
],
"firingTriggerId": ["Purchase Event"]
}
],
"variable": [
{
"name": "ga4 measurement id",
"type": "c",
"parameter": [
{
"key": "value",
"value": "YOUR_GA4_MEASUREMENT_ID"
}
]
},
{
"name": "google ads - conversion id",
"type": "c",
"parameter": [
{
"key": "value",
"value": "YOUR_GOOGLE_ADS_CONVERSION_ID"
}
]
}
],
"trigger": [
{
"name": "Purchase Event",
"type": "CUSTOM_EVENT",
"customEventFilter": [
{
"type": "EQUALS",
"parameter": [
{
"key": "arg0",
"value": "{{_event}}"
},
{
"key": "arg1",
"value": "purchase"
}
]
}
]
}
]
}
}
How to Structure Your Data Layer Objects to Work with This Tool
To ensure that the GTM container works effectively with your website, it’s crucial to properly structure your Data Layer objects. The Data Layer acts as a bridge between your website and GTM, allowing you to pass dynamic data for tracking.
Key Data Layer Variables
Our GTM container expects certain Data Layer variables to be present for enhanced e-commerce tracking:
1. Transaction Details
ecommerce.transaction_id
: Unique identifier for the transaction.ecommerce.value
: Total value of the transaction.ecommerce.currency
: Currency code (e.g., “USD”).ecommerce.tax
: Tax amount.ecommerce.shipping
: Shipping cost.ecommerce.coupon
: Coupon code applied.
2. Item Details
ecommerce.items
: An array of items purchased, each containing:item_id
: Unique identifier for the item.item_name
: Name of the item.price
: Price per item.quantity
: Quantity purchased.item_category
: Category of the item.
3. Event Name
event
: Regex match for all enhanced ecommerce events as well as separate events for purchase and refund
Example Data Layer Structure
Below is an example of how to structure your Data Layer to work with this generator:
<script>
window.dataLayer = window.dataLayer || [];
window.dataLayer.push({
'event': 'purchase',
'ecommerce': {
'transaction_id': 'T12345',
'value': 99.99,
'currency': 'USD',
'tax': 5.00,
'shipping': 0.00,
'coupon': 'SUMMER_SALE',
'items': [
{
'item_id': 'P123',
'item_name': 'Product Name',
'price': 49.99,
'quantity': 1,
'item_category': 'Category A'
},
{
'item_id': 'P124',
'item_name': 'Another Product',
'price': 49.99,
'quantity': 1,
'item_category': 'Category B'
}
]
}
});
</script>
Best Practices for Data Layer Implementation
- Consistency: Ensure that the keys in your Data Layer match exactly with those expected by the GTM container and the code above.
- Event-Driven: Push a new Data Layer event whenever a significant user action occurs (e.g., adding a product to the cart).
- Validation: Regularly test your Data Layer using tools like GTM’s Preview mode to ensure data is being passed correctly.
How to Use the GTM Container Generator
Step 2: Input Your GA4 Measurement ID and Your Google Ads Conversion ID
- GA4 Measurement ID: This is found in your GA4 property under Admin > Data Streams.
- Google Ads Conversion ID: Locate this in your Google Ads account under Goals > Conversions.
Step 3: Generate the GTM Container
Click the “Generate Tag Manager Container” button. The tool will process your inputs and produce a customized GTM container JSON file.
Step 4: Download the JSON File
A download link will be provided. Click “Download JSON File” to save the container to your computer.
Step 5: Import into Google Tag Manager
- Log in to GTM: Access your GTM account.
- Import Container:
- Navigate to Admin > Import Container.
- Select the downloaded JSON file.
- Choose either to Create a New Container or Overwrite Existing Container.
- Review and Confirm: Follow the prompts to review the changes and confirm the import.
Step 6: Publish Your Container
After importing, make sure to Submit and Publish your container to make the changes live.
Testing and Validation
After setting up the GTM container and implementing the Data Layer on your website, it’s important to test everything:
- Use GTM Preview Mode: This allows you to see which tags are firing and inspect the Data Layer in real-time.
- Check GA4 Reports: Verify that events and conversions are being recorded correctly in your Google Analytics property.
- Monitor Google Ads: Ensure that remarketing lists and conversion tracking are functioning as expected.
Frequently Asked Questions
What if I don’t have a GA4 Measurement ID or Google Ads Conversion ID?
You’ll need to set up accounts for Google Analytics 4 and Google Ads to obtain these IDs. Both platforms offer guides to help you get started.
Can I customize the GTM container further?
Absolutely! The generated GTM container serves as a starting point. You can add additional tags, triggers, and variables to meet your specific needs.
Is this tool compatible with non-e-commerce websites?
The tool is optimized for e-commerce tracking. However, you can modify the GTM container after import to suit other types of websites.
Our Free E-commerce Google Tag Manager Container Generator simplifies the process of setting up advanced tracking for your e-commerce website. By automating the creation of a customized GTM container, you can focus on analyzing data and optimizing your marketing strategies.
We hope this tool enhances your ability to track user interactions and conversions effectively. If you have any questions or need assistance, feel free to reach out to our team.