Skip to main content
All CollectionsObservePoint Custom Tag
OP Custom Tag - SEO Validating JSON-LD
OP Custom Tag - SEO Validating JSON-LD
Luiza Gircoveanu avatar
Written by Luiza Gircoveanu
Updated over 2 months ago

Overview

The snippet below grabs the JSON-LD content on a webpage to help you determine if it can be read well by search engines. JSON-LD stands for JavaScript Object Notation for Linked Data and is populated with descriptive "structured data" about the web page in a format the search engines can understand and use. The content of these JSON-LD object is written in different vocabularies. The most popular being schema.org.

This is one of the more advanced SEO practices and its format in addition to its presence is important. There are specific formatting requirements. This is often not included in a basic SEO reporting tool but it is extremely important to SEO marketers who want to raise the relevancy of their pages.

Here's an example of a News Article schema in JSON-LD format. Note the @context variable set to "https://schema.org". This tells search engines referencing the object what vocabulary to anticipate in the object.

<script type="application/ld+json">
{
"@context": "https://schema.org",
"@type": "NewsArticle",
"url": "http://www.bbc.com/news/world-us-canada-39324587",
"publisher":{
"@type":"Organization",
"name":"BBC News",
"logo":"http://www.bbc.co.uk/news/special/2015/newsspec_10857/bbc_news_logo.png?cb=1"
},
"headline": "Trump Russia claims: FBI's Comey confirms investigation of election 'interference'",
"mainEntityOfPage": "http://www.bbc.com/news/world-us-canada-39324587",
"articleBody": "Director Comey says the probe into last year's US election would assess if crimes were committed.",
"image":[
"http://ichef-1.bbci.co.uk/news/560/media/images/75306000/jpg/_75306515_line976.jpg","http://ichef.bbci.co.uk/news/560/cpsprodpb/8AB9/production/_95231553_comey2.jpg"],
"datePublished":"2017-03-20T20:30:54+00:00"
}
</script>

Implementation

Under Variable Summary in ObservePoint data, select the Json-ld account to see the relevant variables.

To capture the following details in an Audit or Journey, paste the snippet below into an Execute Javascript Action:

If no ObservePoint Data tag is found on the page with an account id of "JSON-LD", then no JSON-LD objects were present on the page.

function opReqGetAsync(paramObject, acct, callback) {
var baseURL = "https://opreq.observepoint.com/?acct=" + acct;
var opReq = new XMLHttpRequest();
opReq.onreadystatechange = function() {
if (opReq.readyState == 4 && opReq.status == 200) {
callback(opReq.responseText);
}
}
opReq.open("POST", baseURL, true);
opReq.send(JSON.stringify(paramObject));
}

var jsonLDs = document.querySelectorAll("script[type*='json'][type*='ld']")
for (i = 0; i < jsonLDs.length; i++) {
var data = jsonLDs[i].innerHTML;
var object = JSON.parse(data);
opReqGetAsync(object, "JSON-LD");
}
Did this answer your question?