Skip to content

Instantly share code, notes, and snippets.

using System;
using System.Collections.Generic;
using EPiServer.Core;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.Shell.ObjectEditing;
namespace Foundation.Features
{
public class ReadonlyBlockMetadataExtender : IMetadataExtender
@davidknipe
davidknipe / odp-tracking.js
Last active June 1, 2021 08:08
Optimizely Data Platform tracking script for Foundation sites
// This pops up a modal form when a certain element is clicked (element with id of 'joinButton' in this case)
if (document.getElementById('joinButton')) {
var joinButton = document.getElementById('joinButton');
joinButton.addEventListener("click",
function (event) {
zaius.dispatch(
'web',
'showContent', {
contentId: 'mosey_club_modal_form_message_a_web_modal', // this is the id of the modal from ODP > Campaigns > edit campaign > Content Id
target: {
@davidknipe
davidknipe / OdpOrderConfirmationTrackingInit.cs
Last active May 27, 2021 10:59
Starter code to send order confirmation events to Optimizely Data Platform
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Text;
using System.Web;
using EPiServer.Commerce.Order;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
using EPiServer.ServiceLocation;
@davidknipe
davidknipe / Startup.cs
Created May 2, 2023 14:04
How to configure the Optimizely DAM picker to allow videos
// Omitted for brevity
namespace YourApplication
{
public class Startup
{
// Omitted for brevity
public Startup(IWebHostEnvironment webHostingEnvironment, IConfiguration configuration)
{
EPiServer.Cms.WelcomeIntegration.Core.IDAMAssetIdentityResolver _damAssetIdentityResolver;
var damUrl = "https://images2.welcomesoftware.com/assets/UrlOfImageFromOptimizely.com";
DAMMetadata damMetadata = new DAMMetadata("Title of the asset", DAMAssetType.Image); // Swap to .Video if appropriate
var mappedIdentity = _damAssetIdentityResolver.Get(new Uri(damUrl), JsonSerializer.Serialize<DAMMetadata>(damMetadata), true);
var contentLinkToSave = mappedIdentity.ContentLink;
@davidknipe
davidknipe / DamAltTextHelper.cs
Last active April 29, 2024 15:34
Optimizely DAM alt text helper for Optimizely CMS 12
using EPiServer.Cms.WelcomeIntegration.Core;
using EPiServer.Cms.WelcomeIntegration.Core.Internal;
using EPiServer.Cms.WelcomeIntegration.UI;
using EPiServer.Cms.WelcomeIntegration.UI.Internal;
using Microsoft.Extensions.Caching.Memory;
using Microsoft.Extensions.Options;
using Optimizely.Cmp.Client;
namespace OptimzelyDamHelpers;