Created
October 3, 2019 19:47
-
-
Save jurosko/1120cae84a70a5fcee4c6b100c091077 to your computer and use it in GitHub Desktop.
WordPress - wpml language per domain - How to add GTM, GA
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 | |
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