Last active
July 19, 2018 21:19
-
-
Save remcotolsma/6103897 to your computer and use it in GitHub Desktop.
Analytics tracking code per language (WPML)
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
/** | |
* Google Analytics tracking code per language (WPML) | |
* | |
* @param array $options | |
* @see http://plugins.trac.wordpress.org/browser/google-analytics-for-wordpress/tags/4.3.3/frontend/class-frontend.php#L12 | |
*/ | |
function prefix_ga_init( $options ) { | |
global $yoast_ga; | |
if ( isset( $yoast_ga ) && defined( 'ICL_LANGUAGE_CODE' ) ) { | |
switch ( ICL_LANGUAGE_CODE ) { | |
case 'be': | |
$yoast_ga->options['uastring'] = 'UA-0000000-1'; | |
break; | |
case 'de': | |
$yoast_ga->options['uastring'] = 'UA-0000000-2'; | |
break; | |
case 'en': | |
$yoast_ga->options['uastring'] = 'UA-0000000-3'; | |
break; | |
} | |
} | |
} | |
add_action( 'init', 'prefix_ga_init' ); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
@chriscct7 - Can you give some more insights on how MonsterInsights 6.0+ works with WPML? I wasn't able to find any clear documentation.