'Capturing the 'hostName' for AMP json object

I have a JSON object which basically captures a few custom dimensions. Though everything is coming through, I am unable to capture the hostname. Below is the script.

<script type="application/json">    
{
"vars": { 
"businessUnit": "abc", 
"pageCategory": "xyz",
"pageSubCategory": "premium",
"siteCountry": "us",
"siteLanguage": "en"
},
"extraUrlParams": {
"hostName": "${ampdocHost}"
}
}
</script>

Can anyone suggest how to capture the hostname from above?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source