How to improve SEO with dynamic structured data

Introduction

Usually, when an embed code is generated in THRON to be published into any website, there is a desire for this content to be found by search engines and therefore by the audience. Search engines evaluate a lot of information to determine the level of positioning (ranking) of a content in the list of available results when a user performs a search, and it is therefore important to provide them with as much information as possible on the topic.

When it comes to SEO, in addition to the most familiar concept of "indexing", there is a newer, better but less immediate concept, named "structured data".  Structured data, as stated by Google itself, is a standardized format for providing information about a page and classifying the page content; for example, on a recipe page, what are the ingredients, the cooking time and temperature, the calories, and so on.  Structured data has born to overcome the limitations of the previous indexing approach thus allowing a better ranking and more control over what is seen by the search engine.

 

Indexing

Content's basic information (such as title, description and url) allows search engines to understand that in a particular page there is a specific topic, and therefore to potentially offer the link of that particular page to users who search for such topic.

There are many factors influencing the ranking (position) of the web page in the results of a search, and not all of them are publicly documented. What is certain is that page performance is extremely important, and THRON already offers, thanks to its architecture, meaningful improvements over traditional content embeds thus achieving best performances.

Moreover, THRON Player seamlessly uses all content information, such as content's title and description, to leverage all available data for indexing purposes and make sure search engines understand what each content is about (eg. ALT and TITLE tag on images).

 

Structured data

However, there are cases where indexing may not lead to desired results and a way to achieve disambiguation is necessary, i. e. cases where the keyword used by a user to perform a search could lead to results that have different meanings depending on the context in which they are used. Search engines can attempt to determine the context with different techniques (e. g. previous searches, geolocation, person profile), but their task can be facilitated by structured data: structured data allows to provide context to indexed content leading to a result that is more understandable and useful to the end user, showing, for example, the content type (image, video etc.).
There’s, however, a technological limit in search engines.

Google, for example, uses two different engines for the indexing of content and for the extraction of structured data. The engine that looks for basic content information for indexing purposes is capable of executing javascript code, and is therefore capable of obtaining information that are injected into the page and not present in the source code. THRON Player leverages this capability and injects content title and description into the page's code by retrieving it in real-time via THRON API. By doing this, any change made on content's basic information will be provided to search engines on subsequent scans.

The engine that looks for structured data, currently does not offer the same capability. Structured data must be natively present into the page upon load and can not be injected by the Player in real time. Nonetheless, there are several ways to provide search engines with structured data aligned with content information, but integration should be generated depending on the host page.

In other words, such structured data must be generated server-side. 

 

Generate structured data on server

In order to provide search engine with structured data a small server-side application must be created, the objective of this application is to dynamically generate html tags required to index content.

Please be aware that this implementation requires a careful technical analysis: Thanks to THRON architecture, the Player can withstand a huge amount of requests, but the same number must be borne by the server that injects the data on the page, so you must be careful not to alter the operation of the website itself, especially because of the number of requests.

As we mentioned before, search engines do not run javascript when searching for structured data (yet), so we need to make them available on the page right away. This is possible by changing the page server-side.

We will offer a prototype based on PHP for server-side scripting.

This is an example of embed code of a video content type, provided by THRON, which has the structured data already prepared.

 

<div itemscope itemtype="http://schema.org/VideoObject" >
 <meta itemprop="name" content="<The content's title>" />
 <meta itemprop="description" content="<The content's description>" />
 <meta itemprop="alternateName" content="<Content Title - Content Description>" />
 <meta itemprop="thumbnailUrl" content="https://<clientId>-cdn.thron.com/delivery/public/thumbnail/qaxthron/<xcontentId>/<pkey>/std/1024x576/<prettyName>"
/>
 <meta itemprop="uploadDate" content="2017-10-25T08:18:40.282Z" />
 <meta itemprop="contentUrl" content="https://<clientId>-cdn.thron.com/delivery/public/video/qaxthron/<xcontentId>/<pkey>/<channelName>/<prettyName>"
/>
</div>
<div id="abzvs" style="width: 1024px; height: 576px"></div>
<script src="https://<clientId>-cdn.thron.com/shared/ce/bootstrap/1/scripts/embeds-min.js"></script>

<script>
    var options = {
        clientId: "<clientId>",
        xcontentId: "<xcontentId>",
        sessId: "<pkey>"
    };
    var player = THRONContentExperience("abzvs", options);
</script>

 

Structured data are those contained in the div:

<div itemscope itemtype="http://schema.org/VideoObject" >

And that's where we want to act on the server side. We need a php code that takes care of collecting the necessary information and injects them into the page so that they are always updated every time search engines' software used to search for structured data passes.

First of all, we download content information using xcontentId and pKey. In our example, on our video, we use:

  • description
  • title
  • thumbnail
  • creation date
  • multimedia content

but you can adapt your needs using the many structured data that search engines can manage.

 

function get_content_detail_informations($clientId,$xContentId,$sessId) {
    
    // --- Retrieving Content data 
    $url = "https://".$clientId."-view.thron.com/api/xcontents/resources/delivery/getContentDetail?clientId=".$clientId."&xcontentId=".$xContentId."&templateId=CE1&pkey=".$sessId;
    $ch = curl_init();
    curl_setopt_array($ch, array(
        CURLOPT_RETURNTRANSFER => 1,
        CURLOPT_URL => $url
    ));
    $result = curl_exec($ch);
    curl_close($ch);
    $result = json_decode($result);
    
    // --- Preparing Seo Content data 
    $contentType = $result->content->contentType;
    $seoChannel = "";
    $seoItemType = "";
    if ($contentType == "VIDEO"){
        $seoChannel = "WEBHD";
        $seoItemType = "http://schema.org/VideoObject";
    }
    
    $contentName = $result->content->locales[0]->name;
    $contentDescription = $result->content->locales[0]->description;
    $contentThumbnail = "https://".$clientId."-cdn.thron.com/delivery/public/thumbnail/".$clientId."/".$xContentId."/".$sessId."/std/1024x576/".$contentName;
    $contentAlternateName = $contentName;
    $contentUrl = "https://".$clientId."-cdn.thron.com/delivery/public/".$contentType."/".$clientId."/".$xContentId."/".$sessId."/".$seoChannel."/".$contentName;
    $contentLastUpdate = $result->content->lastUpdate;
    
    // --- Returning Seo Content data 
    $data=new stdClass();
    $data->name = $contentName;
    $data->description = $contentDescription;
    $data->alternateName = $contentAlternateName;
    $data->description = $contentDescription;
    $data->thumbnailUrl = $contentThumbnail;
    $data->contentUrl = $contentUrl;
    $data->itemType = $seoItemType;
    $data->uploadDate = $contentLastUpdate;
    return $data;
    
}

 

At this point, we need a code that takes these data and injects them into the structured data block:

 

function seo_optimize($clientId,$xContentId,$sessId) {
    $seoData = get_content_detail_informations($clientId, $xContentId, $sessId);
$structured_data = <<<EOT
<div itemscope itemtype="$seoData->itemType" >
    <meta itemprop="name" content="$seoData->name" />
    <meta itemprop="description" content="$seoData->description" />
    <meta itemprop="alternateName" content="$seoData->alternateName" />
    <meta itemprop="thumbnailUrl" content="$seoData->thumbnailUrl" />
    <meta itemprop="contentUrl" content="$seoData->contentUrl" />
    <meta itemprop="uploadDate" content="$seoData->uploadDate" />
</div>
EOT;
print $structured_data;    
} 

 

Once this is done, we remove the statically structured data block generated by the THRON embed code generator and replace it with a php call that injects the data loaded in real time by THRON, and thus dynamically linked to the content itself:

 

<?php include 'SEO.php';
?>
<!doctype html>
<head>
</head>
<body>
<?php seo_optimize("<clientId>","<xcontentId>","<pkey>");
?>
<div id="ofmet" style="width: 640px; height: 400px;"></div>
<script src="https://<clientId>-cdn.thron.com/shared/ce/bootstrap/1/scripts/embeds-min.js"></script>
<script>
    var options = {
        clientId: "<clientId>",
        xcontentId: "<xcontentId>",
        sessId: "<pkey>"
    };
    var player = THRONContentExperience("ofmet", options);
</script>
</body>

 

Thanks to this intervention, every time the content is changed in THRON, the structured data collected by search engines will be updated in real time and search results will also improve thanks to providing structured data to search engine.

Was this article helpful?
0 out of 0 found this helpful

Have any question?

Open a ticket
Comments