-
-
Save laurenancona/ce8fcf4d4934f25caf2d9c3402031d12 to your computer and use it in GitHub Desktop.
JSON-LD GTM Tag
This file contains hidden or 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
<script> | |
(function(){ | |
var data = { | |
"@context": "http://schema.org", | |
"@type": "BlogPosting", | |
"mainEntityOfPage": { | |
"@type": "WebPage", | |
"@id": {{Page URL}} | |
}, | |
"headline": {{SCHEMA - Article Headline}}, | |
"image": { | |
"@type": "ImageObject", | |
"url": {{SCHEMA - Article Image}}, | |
"height": 413, | |
"width": 1159 | |
}, | |
"datePublished": {{SCHEMA - Article datePublished}}, | |
"author": { | |
"@type": "Organization", | |
"name": {{SCHEMA - Author Name}} | |
}, | |
"publisher": { | |
"@type": "Organization", | |
"name": "City of Philadelphia", | |
"logo" : { | |
"@type": "ImageObject", | |
"url": "http://cityofphiladelphia.github.io/patterns/images/city-of-philadelphia.png", | |
"height": 126, | |
"width": 449 | |
} | |
}, | |
"description": {{SCHEMA - Article Description}} | |
} | |
var dateModified = {{SCHEMA - Article dateModified}}; | |
if(dateModified){ | |
data.dateModified = dateModified; | |
} else { | |
data.dateModified = {{SCHEMA - Article datePublished}}; | |
} | |
var script = document.createElement('script'); | |
script.type = "application/ld+json"; | |
script.innerHTML = JSON.stringify(data); | |
document.getElementsByTagName('head')[0].appendChild(script); | |
})(document); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment