LATAM watsonx Orchestrate

IBM LATAM watsonx Orchestrate

 View Only

Latest blogs

<p>
<script>
window.addEventListener('load', function() {
  // Read page type from URL
  function detectPageType(path) {
    path = path.toLowerCase();
    if (path.includes('/discussion/')) return 'discussion-thread';
    if (path.includes('/question/')) return 'question-page';
    if (path.includes('/blogs/')) return 'blog-post';
    if (path.includes('/recent-community-events')) return 'event-list';
    if (path.includes('/viewdocument/')) return 'library-resource';
    if (path.includes('/groups/community-home')) return 'community-home';
    return 'unknown';
  }
  // Read community key from URL
  function extractCommunityKey(url) {
    if (!url) return null;
    var match = url.toLowerCase().match(/communitykey=([a-z0-9\-]+)/);
    return match ? match[1] : null;
  }
  var pageType = detectPageType(window.location.pathname);
  var communityKey = extractCommunityKey(window.location.href);
  // Only trust the h1 as community name on community home pages
  var h1 = document.querySelector('h1');
  var communityName = (pageType === 'community-home' && h1) ? h1.innerText.trim() : null;

  function writeDDO() {
    var dd = window.digitalData;
    if (!dd || !dd.page || !dd.page.pageInfo) return false;
    dd.page.pageInfo.pageType = pageType;
    dd.page.pageInfo.communityKey = communityKey;
    if (communityName) {
      dd.page.pageInfo.communityName = communityName;
      var productName = communityName.indexOf('IBM ') === 0 ? communityName : 'IBM ' + communityName;
      dd.page.taxonomy = dd.page.taxonomy || {};
      dd.page.taxonomy.productName = productName;
      dd.page.taxonomy.pageHeading = communityName;
      dd.page.taxonomy.pageType = 'Community - ' + pageType;
    }
    console.log("DDO updated:", {
      pageType: pageType,
      communityKey: communityKey,
      communityName: communityName,
      taxonomy: dd.page.taxonomy
    });
    return true;
  }

  // Retry in case digitalData is not ready yet
  if (!writeDDO()) {
    var tries = 0;
    var timer = setInterval(function() {
      if (writeDDO() || tries > 20) clearInterval(timer);
      tries = tries + 1;
    }, 500);
  }
});
</script>
</p>