Google Tag Manager (GTM) provides a flexible and powerful platform for managing various tags, triggers, and variables on websites and mobile apps. While GTM supports many out-of-the-box tag templates for common services like Google Analytics, AdWords, and Facebook Pixel, there are often situations where you need to implement custom tags for proprietary platforms or third-party services that don’t have a native tag template in GTM.
Creating custom tags for proprietary platforms in GTM allows you to manage your tracking and analytics requirements in a streamlined way, without having to modify the website code every time a new tag is added. This guide will walk you through the process of setting up custom tags for proprietary platforms in Google Tag Manager.
What Are Custom Tags in Google Tag Manager?
Custom tags in Google Tag Manager are user-defined tags that allow you to execute custom JavaScript or integrate with third-party services that don’t have pre-configured tag templates in GTM. These tags can be used to track interactions, load scripts, or send data to proprietary platforms for analytics, marketing, or other business purposes.
Custom tags can be categorized into:
- Custom HTML Tags: These are JavaScript-based tags that can be used to embed proprietary tracking code or scripts from third-party platforms.
- Custom Image Tags: These are used for tracking pixel tags where an image is dynamically loaded when specific triggers occur.
Steps to Set Up Custom Tags for Proprietary Platforms in Google Tag Manager
Step 1: Identify the Tag Type and Requirements
Before adding a custom tag in GTM, you need to understand what type of custom code or tracking is required by the proprietary platform. This will often be specified in the platform’s documentation. For example, a proprietary platform may require you to use a custom JavaScript snippet or a tracking pixel to log events or send user data.
Ensure you have the following:
- The code or script that needs to be executed for the proprietary platform (this is typically provided by the platform’s documentation).
- Any required parameters or variables (such as user IDs, session details, event names, etc.) that need to be passed to the platform.
Step 2: Access Your Google Tag Manager Account
- Go to the Google Tag Manager website and log in with your Google account.
- Select the relevant container for the website or mobile app where you want to set up the custom tag.
Step 3: Create a New Custom Tag
To create a new custom tag in GTM for your proprietary platform, follow these steps:
- Navigate to the Tags Section:
- In the GTM dashboard, click on Tags from the left-hand navigation menu.
- Click on “New”:
- Click the New button to create a new tag.
- Choose Tag Type:
- Choose the appropriate tag type. If you’re adding a custom JavaScript snippet, you would select Custom HTML from the tag configuration options.
- If you’re adding an image pixel or a tracking image, select Custom Image.
- Enter the Custom Tag Code:
- For Custom HTML Tags: In the tag configuration, paste the custom JavaScript code or tracking script provided by the proprietary platform. This code can include standard tracking events, pixel data, or even additional JavaScript to process dynamic data.
- For Custom Image Tags: Provide the URL of the image (such as a tracking pixel URL) and any dynamic parameters needed (e.g., user ID, session ID).
Example of a custom HTML tag (e.g., a tracking script):
Example of a custom image tag (e.g., a pixel):
Step 4: Add Trigger to Fire the Tag
Once the custom tag has been added, you need to set up a trigger to determine when the tag will fire. The trigger defines the conditions that need to be met for the custom tag to be executed. You can create various types of triggers based on user interactions or page loads.
- Click on “Triggering”:
- In the tag configuration screen, click on the Triggering section to add a trigger.
- Select an Existing Trigger or Create a New One:
- If you have an existing trigger (such as a page view or button click), select it from the list.
- If you need to create a new trigger, click New, choose the appropriate trigger type (e.g., Page View, Click, Form Submission, etc.), and configure it according to your needs. For example, if you want to fire the tag on all page views, select the Page View trigger.
Example Trigger: Fire on all page views:
- Choose Page View > All Pages.
- Save the Trigger:
- After configuring the trigger, click Save to apply it.
Step 5: Test the Custom Tag
After creating the custom tag and trigger, you should always test your setup before publishing it. GTM provides a Preview mode that allows you to see if the tag fires correctly on the specified pages or events.
- Click on “Preview”:
- In the GTM interface, click the Preview button to enter preview mode.
- Check Tag Firing:
- Once in preview mode, visit the website or page where the tag is supposed to fire.
- Use the Tag Assistant (which will appear at the bottom of your browser) to check if the custom tag is firing as expected.
- Check for Errors:
- If the tag is not firing, check the JavaScript console for any errors in the tag’s code or network requests.
Step 6: Publish the Tag
Once you’ve confirmed the tag is firing correctly, you can publish your changes.
- Submit Changes:
- After testing, click on Submit in the GTM dashboard.
- Add a version name and description (e.g., “Added Custom Tag for Platform XYZ”) for version control.
- Publish:
- Click Publish to make the custom tag live on your website or app.
Step 7: Monitor the Custom Tag’s Performance
After deploying the custom tag, monitor its performance to ensure it is correctly tracking events and sending data to the proprietary platform. You can do this by:
- Checking the proprietary platform’s dashboard or analytics interface to verify that the data is being received.
- Using GTM’s Debug Mode or browser developer tools to confirm that the tag is firing correctly during the relevant actions.
Best Practices for Setting Up Custom Tags for Proprietary Platforms
- Dynamic Variables: Use GTM variables to pass dynamic data to the custom tag. For example, use built-in variables like
{{Page URL}}
,{{Transaction Value}}
, or{{User ID}}
to pass real-time data to your proprietary platform. - Data Layer: Utilize the GTM Data Layer to push dynamic data from your website into GTM, which can then be referenced in your custom tags.
- Testing: Always thoroughly test the custom tags in GTM’s Preview mode before publishing them to ensure that they work as expected and are sending the correct data.
- Version Control: Use GTM’s version control features to manage changes to your tags. Label each change or update with a clear description to keep track of modifications.
- Error Handling: Consider adding error handling in your custom JavaScript to catch issues, such as if the proprietary platform’s endpoint is unreachable or if certain dynamic variables are missing.
- Privacy Compliance: Ensure that the data sent to proprietary platforms complies with privacy laws, such as GDPR or CCPA, especially if you’re collecting personal data. Always obtain user consent where necessary.
Conclusion
Setting up custom tags for proprietary platforms in Google Tag Manager provides flexibility to manage non-standard tracking implementations and integrate various third-party services with ease. By following the steps outlined above, you can create custom HTML or image tags, configure triggers, and ensure they work smoothly across your site or app. Testing thoroughly and applying best practices like dynamic variables, data layer usage, and version control will help optimize your GTM setup and ensure reliable data tracking.