• Hi,

    I am using WPML with 2 domains. Each language has its own domain and when I go to google analytics, all data goes to the main website google analytics account.

    How can I setup so every domain has its own google analytics tracking? I have different tag manager containers for each language.

    Is there a guide somewhere for the right setup?

    Thanks in advance!

Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Author Thomas Geiger

    (@duracelltomi)

    You can currently enter one GTM container ID per site.

    If you are using WPML, I assume that both domains have the same site structure and logic, therefore you might want to setup your tracking the same way on both sites, only account/property IDs might differ.

    I would go with one container for both domains and use a Lookup Table variable in GTM to let GTM choose the proper GA4 measurement ID based on the Page Hostname variable.

    Thread Starter bollo81

    (@bollo81)

    Hi Thomas,

    Thank you very much for your reply. It used to work with the code below for the German version of the site. But somehow, after I updated the plugin this doesn’t work anymore (looks like GTM script is loaded twice).

    <?php if( ICL_LANGUAGE_CODE=='de' ) : ?>
    
    <!-- Google Tag Manager Germany -->
    
    <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
    
    new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
    
    j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
    
    'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
    
    })(window,document,'script','dataLayer','GTM-XXXXXXX');</script>
    
    <!-- End Google Tag Manager Germany -->
    Plugin Author Thomas Geiger

    (@duracelltomi)

    If will only work if you turn off “Container code ON/OFF” option, in that case you are in charge to output the container code on each page.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘GTM4WP – different languages’ is closed to new replies.