duracelltomi / gtm4wp

Google Tag Manager plugin for WordPress
https://gtm4wp.com/
GNU General Public License v3.0
147 stars 95 forks source link

WPML multisite different tags #270

Open jacob-v-dam opened 1 year ago

jacob-v-dam commented 1 year ago

Hello,

I noticed it is possible to use the WP multisite option. But how to enable WPML multisite?

We have a website running on different domain for each language. We would like to set a tag per domain.

duracelltomi commented 1 year ago

I was thinking on this several times.

What would be the purpose to enter a different GTM container ID for each language domain if the site structure is the same? In GTM, you can use Lookup Table variable to fire different account/measurement IDs on each domain. Are there any circumstances where you need a different tracking setup (besides proper IDs)?

wailabsdev commented 4 months ago

Hi in wp-config.php after

/* Sets up WordPress vars and included files. / require_once ABSPATH . 'wp-settings.php';

add this:

$current_language = apply_filters( 'wpml_current_language', null );
    if ( $current_language === "lt" ) {
        define( 'GTM4WP_HARDCODED_GTM_ID', 'GTM-xxxxxxx' );
    } elseif ( $current_language === "lv" ) {
        define( 'GTM4WP_HARDCODED_GTM_ID', 'GTM-yyyyyyy' );
    } elseif ( $current_language === "fi" ) {
        define( 'GTM4WP_HARDCODED_GTM_ID', 'GTM-ccccccc' );
    } else {
        define( 'GTM4WP_HARDCODED_GTM_ID', 'GTM-hhhhhhh' );

    }
duracelltomi commented 4 months ago

I still struggle to understand the use case here. What do you want to track differently on a website that has the same content but in different languages?