Hi,
Thanks for your question!
There is a constant defined with my plugin:
GTM4WP_WPFILTER_COMPILE_DATALAYER
You may use this to add a WordPress filter hook and add whatever you want to the data layer:
function my_dl_content( $dl ) {
$dl[ "myData" ] = "Something";
return $dl
}
add_filter( GTM4WP_WPFILTER_COMPILE_DATALAYER, "my_dl_content" );
However in your specific case I think there is no need to add such code to your site: you may simply create a Custom JavaScript Variable on the GTM UI where you can use a simple JS code to extract the country code:
function() {
var pu = {{Page URL}},
pu_parts = pu.split( "." );
if ( pu_parts.length > 2 ) {
return pu_parts[0]; // return first subdomain
} else {
return "en"; // fallback default value
}
}