Back to Community

How to Handle Multi-Currency and Unsupported Currencies in GTM4WP

Content

Many WordPress site owners using WooCommerce with the 'GTM4WP – A Google Tag Manager (GTM) plugin for WordPress' encounter a common challenge: ensuring accurate currency data is sent to analytics and advertising platforms. This is especially prevalent for stores operating with multiple currencies or using a currency code not supported by Google Analytics. This guide explains why this happens and outlines the most effective workarounds.

Why This Problem Occurs

The GTM4WP plugin is designed to integrate seamlessly with WooCommerce's native functions. It pulls the active currency code using the get_woocommerce_currency() PHP function and pushes this data into the data layer. This data is then read by your tags in Google Tag Manager.

The issue arises in two scenarios:

  1. Unsupported Currencies: Google Analytics has a specific list of supported currencies (like USD, EUR, GBP). If your WooCommerce store uses an unsupported currency (e.g., IRT), the ecommerce data sent to Analytics will be invalid and likely rejected, resulting in missing transactions.
  2. Multi-Currency Incompatibility: While the plugin can work with multi-currency setups if the currency-switching solution correctly uses WooCommerce's built-in filters, some configurations or specific plugins may not integrate perfectly, leading to the base currency always being sent instead of the active customer currency.

Common Solutions and Workarounds

Solution 1: Custom JavaScript Variable in Google Tag Manager (Recommended)

Since the GTM4WP plugin itself does not have a built-in setting to override the currency code, the most common solution is to manipulate the data within Google Tag Manager after it has been pushed to the data layer. This method is non-destructive and gives you full control.

Step-by-Step Guide:

  1. Create a Data Layer Variable: In your GTM workspace, create a new variable.
    • Type: Data Layer Variable
    • Data Layer Variable Name: ecommerce
    • Name this variable: dlv - ecommerce
  2. Create a Custom JavaScript Variable: Create another new variable to transform the data.
    • Type: Custom JavaScript
    • Use code similar to the following:
      function() {
        var ecommerceData = {{dlv - ecommerce}};
        if (ecommerceData && ecommerceData.currencyCode) {
          // Replace 'IRT' with 'USD' or your desired supported currency
          if (ecommerceData.currencyCode === 'IRT') {
            ecommerceData.currencyCode = 'USD';
            // Optional: Convert the monetary values if needed
            // ecommerceData.purchase.actionField.revenue = (ecommerceData.purchase.actionField.revenue * 0.000024).toFixed(2);
          }
        }
        return ecommerceData;
      }
      
    • Name this variable: js - ecommerce converted currency
  3. Update Your Tags: Find your Google Analytics tags (e.g., GA4 event tags, UA ecommerce tags). Change the field where the data layer variable {{ecommerce}} is used (often in the 'Ecommerce' settings) to reference your new custom JavaScript variable {{js - ecommerce converted currency}} instead.

Solution 2: Check Your Multi-Currency Plugin Integration

If you are using a multi-currency plugin like WPML, test if it is working correctly with GTM4WP. The plugin should hook into WooCommerce's get_woocommerce_currency() function to return the correct currency based on the user's session or location.

How to Test:

  1. Use your browser's developer tools (F12) and go to the Console tab.
  2. Type dataLayer and press Enter to view its contents.
  3. Navigate your site, change the currency, and check the currencyCode value in the ecommerce objects within the data layer. If it changes to match the frontend currency, your setup is working. If it always shows the base currency, the multi-currency plugin may not be fully compatible.

Conclusion

Handling currency issues with the GTM4WP plugin typically requires intervention within Google Tag Manager rather than in the plugin's WordPress settings. The Custom JavaScript variable method provides a powerful and flexible way to ensure your ecommerce data is sent with a Google-supported currency code, preserving the integrity of your analytics and ad tracking.

For developers, the 'GTM4WP – A Google Tag Manager (GTM) plugin for WordPress' team has noted that a built-in filter hook to override the currency code is a potential future enhancement. Until then, the GTM workaround is the standard solution recommended by the community.

Related Support Threads Support