UGC Microdata Setup

Add Viafoura data to optimize your page for search engines like Google.

The Viafoura API's return the data needed for SEO optimization. See the steps below as an example of how to add Conversations data for SEO.

To create data using the Viafoura Conversations API and incorporate it into a script tag with type application/ld+json of an article with the vf-conversations widget, follow these steps:

Step 1: Retrieve Article Information
Retrieve the necessary information for the article from your client's source. Here's an example for this page of our demo site:

const articleData = {
  "headline": "Here Are What Media Companies Are Doing to Deal With COVID-19 Information Overload",
  "thumbnailUrl": "",
  "description": "With COVID-19 disrupting the world, the demand for news has never been greater. Newsrooms are being pushed to their limits as they test the most time-saving yet effective methods to sift through an infinite amount of coronavirus information, craft story after story and keep their teams safe.",
  "url": "",
  "image": {
    "@context": "",
    "@type": "ImageObject",
    "url": "",
    "width": "1778",
    "height": "1000"

Step 2: Retrieve Comments from Viafoura API
Use the Viafoura API to fetch comments. Replace <SITE_UUID> with the value provided by Viafoura, and <CONTAINER_ID> with the value used in vf-conversations or the meta tag vf:container_id.

fetch(`<SITE_UUID>?limit=10&container_id=<CONTAINER_ID>&reply_limit=2&sorted_by=newest`, {
  method: 'GET',
  headers: {
    Accept: "application/json",
    "Content-Type": "application/json",
.then(response => response.json())
.then(data => {
  const comments = => ({
    "@context": "",
    "@type": "Comment",
    "datePublished": new Date(comment.date_created).toISOString().split("T")[0],
    "text": comment.content,
    "upvoteCount": comment.total_likes,
    "downvoteCount": comment.total_dislikes

  // Combine article data and comments into one object
  const schemaOrgData = {
    "@context": "",
    "@type": "Article",
    "headline": articleData.headline,
    "name": articleData.headline,
    "thumbnailUrl": articleData.thumbnailUrl,
    "description": articleData.description,
    "url": articleData.url,
    "image": articleData.image,
    "commentCount": comments.length,
    "comment": comments

  // Embed data into <script> tag
  const scriptTag = document.createElement('script');
  scriptTag.type = 'application/ld+json';
  scriptTag.text = JSON.stringify(schemaOrgData);
.catch(error => console.error('Error fetching comments:', error));

Step 3: Embed Data
Finally, the data including both the article information and the comments will be embedded within a

  <!-- Other meta tags, styles, and scripts -->
  <script type="application/ld+json">
    {/* The data generated in Step 2 will be inserted here */}

Ensure that the script is executed at a time when you have at least 10 comments. In terms of performance, it's generally more efficient to create the JSON on the server side, where it can be cached to reduce the need for repeated generation of the same data.

Step 4: Verify your
Once this is published on your site, you can verify that this is working as expected by checking the URL of an article in the Rich Results Test site provided by Google. For this tutorial, you can check the end result in this link.