Skip to content

Instantly share code, notes, and snippets.

@davidknipe
davidknipe / OdpOrderConfirmationTrackingInit.cs
Last active May 27, 2021
Starter code to send order confirmation events to Optimizely Data Platform
View OdpOrderConfirmationTrackingInit.cs
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 / odp-tracking.js
Last active Jun 1, 2021
Optimizely Data Platform tracking script for Foundation sites
View odp-tracking.js
// 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: {
View ReadonlyBlocks.cs
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
View ProjectUndoInit.cs
using System;
using System.Collections.Generic;
using System.Linq;
using EPiServer;
using EPiServer.Core;
using EPiServer.Data.Entity;
using EPiServer.DataAbstraction;
using EPiServer.DataAccess;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
View OrderEventsInit.cs
using EPiServer.Commerce.Order;
using EPiServer.Framework;
using EPiServer.Framework.Initialization;
namespace Foundation._EuromonitorExample
{
[InitializableModule]
[ModuleDependency(typeof(EPiServer.Web.InitializationModule))]
public class OrderEventsInit : IInitializableModule
{
@davidknipe
davidknipe / CreateGetaCategoriesFromEpiserverCategoriesJob.cs
Created Oct 10, 2019
Create Geta Categories based on existing Episerver category structure
View CreateGetaCategoriesFromEpiserverCategoriesJob.cs
using System.Collections.Generic;
using System.Linq;
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.PlugIn;
using EPiServer.Scheduler;
using Foundation.Cms.Categories;
using Geta.EpiCategories;
using Geta.EpiCategories.Extensions;
@davidknipe
davidknipe / MigrateContentToGetaCategoriesJob.cs
Last active Oct 13, 2019
Migrates content to use Geta Categories. Note will only migrate categories that exist in the Geta Categories structure.
View MigrateContentToGetaCategoriesJob.cs
using System.Collections.Generic;
using System.Linq;
using EPiServer;
using EPiServer.Core;
using EPiServer.DataAbstraction;
using EPiServer.PlugIn;
using EPiServer.Scheduler;
using EPiServer.Security;
using Foundation.Cms.Categories;
using Geta.EpiCategories;
@davidknipe
davidknipe / PostClickInterceptor.cs
Last active Aug 6, 2019
Episerver tracking data interceptor to create Episerver Campaign post clicks from Episerver Insight tracking events
View PostClickInterceptor.cs
using System.Configuration;
using System.Linq;
using System.Net;
using System.Web;
using System.Web.Hosting;
using Episerver.Marketing.Common.Helpers;
using EPiServer.ServiceLocation;
using EPiServer.Tracking.Commerce.Data;
using EPiServer.Tracking.Core;
using EPiServer.Tracking.PageView;
View TrackEmailClick.cs
public static void TrackEmailClick(HttpContextBase httpContext, EPiServer.Tracking.Core.ITrackingService trackingService)
{
try
{
var email = GetCurrentUserEmail();
// If you know the users name and/or additional information
// like company name it's also possible to associate here
var userData = new UserData() { Name = email, Email = email };
var trackingData = new TrackingData<object>
{
@davidknipe
davidknipe / index.js
Last active Jun 19, 2018
Alexa skill for Episerver Music Festival to show of the Content Delivery API
View index.js
'use strict';
// --------------- Helpers that build all of the responses -----------------------
var http = require('http');
var axios = require('axios');
var striptags = require('striptags');
function buildSpeechletResponse(title, output, repromptText, shouldEndSession) {
return {