To take full advantage of MediaOS outside of a WordPress environment—such as enabling paywalls, comments, personalization, or other engagement features—you must include structured JSON data in the header of each page. This data helps MediaOS understand the context of the page, including post details, author, categories, and more.
Why This Is Required #
When you’re not using WordPress, MediaOS doesn’t have native access to page-level metadata. To ensure full functionality, you need to include a window.mediaos
object in your page header. This manually passes key data that allows MediaOS tools—like paywalls, comment feeds, content targeting, and personalization—to function properly. It enables features such as paywall activation, comment feeds linked to specific posts, dynamic ad and content targeting, newsletter content blocks, and reader engagement analytics.
Example Script #
Include the following <script> tag in the <head> of your HTML page (or at the top of the <body> if needed):
<script>
window.mediaos = {
"mediaos_version": 1,
"url": "http://yourdomain.com/2024/08/21/ethereum-record-high/",
"post_id": 26,
"title": "Bitcoin’s Main Rival Ethereum Hits A Fresh Record High: $425.55",
"excerpt": "",
"author_id": "1",
"author_name": "user",
"author_avatar": "https://secure.gravatar.com/avatar/f8a32e1d7009fd849f21877ea51ab473?s=96&d=mm&r=g",
"category_ids": {
"2": "Business",
"9": "Cryptocurrency",
"4": "Markets",
"7": "Real Estate"
},
"post_type": "post",
"tags": "Bitcoin,Business Analysis,Investment Loss,Market Stories,Oil Market,Wall Street",
"date": 1724267860,
"route": "",
"featured_image": "http://yourdomain.com/wp-content/uploads/2024/09/news5.jpg",
"content_tag_id": "#post_content_single"
};
window.mediaoshub = true;
</script>
Note: Replace the values with data from your actual article or page. The JSON object must reflect the real-time context of the page it’s embedded in.
Explanation of Fields #
Field | Description |
---|---|
mediaos_version |
Current version of the MediaOS integration object. Always use 1 . |
url |
Full URL of the current page. |
post_id |
Unique ID of the article or content item. |
title |
Full title of the content. |
excerpt |
Short excerpt or summary. Can be left blank if unused. |
author_id |
Internal ID of the content author. |
author_name |
Author display name. |
author_avatar |
URL to the author’s avatar or profile image. |
category_ids |
Key-value pairs where keys are category IDs and values are category names. |
post_type |
The type of content (e.g., post , article , story ). |
tags |
Comma-separated list of content tags. |
date |
UNIX timestamp representing the original publish date. |
route |
Optional routing identifier. Can be left empty. |
featured_image |
URL of the featured image or thumbnail. |
content_tag_id |
CSS selector for the main content container (e.g., #post_content_single ). |
Tip: If you’re not using WordPress, make sure content_tag_id matches the main HTML element containing the article body (e.g., #main-article, #post_body).
Required for Key Feature #
Adding this script is essential for several core MediaOS features to work properly outside of WordPress. It enables functionality for components like <mediaos-comment-feed>, as well as paywalls, personalization, content tagging and targeting, newsletter smart blocks, reader behavior tracking, and page-specific analytics. Without it, these tools won’t function as intended on non-WordPress pages.
Warning: If this object is missing or improperly configured, MediaOS will not be able to associate actions (like comments or paywall views) with the correct post.