Skip to content

Instantly share code, notes, and snippets.

@jurosko
Created October 3, 2019 19:47
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jurosko/1120cae84a70a5fcee4c6b100c091077 to your computer and use it in GitHub Desktop.
Save jurosko/1120cae84a70a5fcee4c6b100c091077 to your computer and use it in GitHub Desktop.
WordPress - wpml language per domain - How to add GTM, GA
<?php
function vj_header_scripts() {
switch ( ICL_LANGUAGE_CODE ) {
case "sk":
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async
src="https://www.googletagmanager.com/gtag/js?id=UA-11111111-1"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-11111111-1');
</script>
<?php
break;
case "en":
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async
src="https://www.googletagmanager.com/gtag/js?id=UA-11111111-2"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-11111111-2');
</script>
<?php
break;
case "de":
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async
src="https://www.googletagmanager.com/gtag/js?id=UA-11111111-3"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-11111111-3');
</script>
<?php
break;
case "pl":
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async
src="https://www.googletagmanager.com/gtag/js?id=UA-11111111-4"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-11111111-4');
</script>
<?php
break;
case "hu":
?>
<!-- Global site tag (gtag.js) - Google Analytics -->
<script async
src="https://www.googletagmanager.com/gtag/js?id=UA-11111111-5"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag() {
dataLayer.push(arguments);
}
gtag('js', new Date());
gtag('config', 'UA-11111111-5');
</script>
<?php
break;
}
}
add_action( 'wp_head', 'vj_header_scripts', 0 );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment