HomeDev GuideAPI Reference
Dev GuideAPI ReferenceUser GuideGitHubNuGetDev CommunitySubmit a ticketLog In
GitHubNuGetDev CommunitySubmit a ticket

Connect for Acoustic (Silverpop)

Connects Acoustic (Silverpop) with Optimizely Forms, letting marketers collect visitor data, and pass that on to be used with Silverpop.

The Optimizely Connect for Acoustic (formerly Watson Marketing, formerly Silverpop) add-on is part of Optimizely Connect for Marketing Automation.

Prerequisites

An Optimizely Content Management System (CMS) installation with Optimizely Forms, and the required Marketing Automation connector components.

Install

The Connect for Acoustic (Silverpop) MA connector is installed through the NuGet package EPiServer.MarketingAutomationIntegration.Silverpop. See Add-ons platform compatibility for supported Optimizely versions.

Configure

To configure your Optimizely website to use Acoustic (Silverpop), you need an Acoustic (Silverpop) license that provides you with a username, password, and company name. You also must configure the connection of form fields to Acoustic (Silverpop), so that data from the specified fields can be sent to Acoustic (Silverpop).

These configurations are described in Acoustic (Silverpop) connector (CMS 12) and in the Optimizely CMS User Guide.

Encrypt credentials

Credentials are encrypted and saved based on one of the following options:

  • MAICryptoKey – AES encryption with an SHA256-computer hash, based on the value of the key.
    This key should be specified at the root level of the appsettings.json file with any string as its value.
  • machineKey of the server.
    The machineKey encryption is used ONLY if MAICryptoKey is not specified. If you neglect to specify an MAICryptoKey in appsettings.json, the credentials are removed when the DXP instance is restarted
    because the machineKey is different and will fail to decrypt the credentials, so you must save credentials again through the configuration screen.

If the credentials are already encrypted using machineKey in an existing site, and the MAICryptoKey setting is added, then the credentials are deleted and must be re-entered.

📘

Note

The MAICryptoKey must be specified with the same value in ALL the DXP instances that are connected to the same database. If it is missing or the value is different in any of the instances, the credentials will be deleted and must be re-entered.

Customize Acoustic

This section describes how to customize mailing templates using the Optimizely Connect for Acoustic (Silverpop) add-on.

Acoustic (Silverpop) provides the base class SilverpopMailingPageBase to create a mailing template, which contains all required properties. You can add custom properties to construct a mailing template by inheriting it.

The following code samples apply to a web form on the Optimizely Content Management System (CMS) "Alloy" sample site.

  1. Create the content type page as follows:

    using EPiServer.Core;
    using EPiServer.DataAbstraction;
    using EPiServer.DataAnnotations;
    using EPiServer.MarketingAutomationIntegration.Core;
    using EPiServer.MarketingAutomationIntegration.Silverpop.Enums;
    using EPiServer.MarketingAutomationIntegration.Silverpop.Implementation;
    using EPiServer.MarketingAutomationIntegration.Silverpop.UI.PageTypes;
    using System.ComponentModel.DataAnnotations;
            
    namespace EPiServer.Templates.Alloy.Models.Pages
      {
        [ContentType(GroupName = "Connect For Marketing Automation")]
        [ImageUrlAttribute("~/Static/gfx/SilverpopMailingPage_Preview.png")]
        public class MySilverpopMailingPage : SilverpopMailingPage
          {
            [BackingType(typeof(PropertyString))]
            [Display(GroupName = EPiServer.MarketingAutomationIntegration.Constants.MAIPageTypeTabs, Order = 40)]
            public virtual string MyCustomProperty { get; set; }
          }
       }
    
  2. Create the template file with the following markup:

    <%@ Page Language="C#" 
             AutoEventWireup="true" 
             EnableViewState="false"
             CodeBehind="SilverpopMailingPageTemplate.aspx.cs"
             Inherits="EPiServer.Templates.Alloy.Views.Pages.SilverpopMailingPageTemplate" %>
            
      <!DOCTYPE html>
        <html lang="en">
          <head runat="server">
            <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
            <meta name="viewport" content="width=device-width" />
            
            <!-- For injecting script resource into Mailing template page at header -->
            <EPiServer:RequiredClientResources RenderingArea="Header" ID="RequiredResourcesHeader" runat="server" />
          </head>
          <body>
            <EPiServer:Property runat="server" PropertyName="MyCustomProperty" />
            <form runat="server">
              <EPiServer:Property runat="server" PropertyName="HTMLBody" />
            </form>
            
            <!-- For injecting script resource into Mailing template page at footer -->
            <EPiServer:RequiredClientResources RenderingArea="Footer" ID="RequiredResourcesFooter" runat="server" />
          </body>
        </html>
    

    In code behind it should look as follows:

    using EPiServer.Framework.DataAnnotations;
    using EPiServer.Templates.Alloy.Models.Pages;
         
    namespace EPiServer.Templates.Alloy.Views.Pages
      {
        [TemplateDescriptor(Path = "~/Views/Pages/SilverpopMailingPageTemplate.aspx")]
        public partial class SilverpopMailingPageTemplate : TemplatePage<SilverpopMailingPage>
          {
          }
      }
    
  3. Compile and run your project.

Customize opt-in or opt-out functionality

You can develop opt-in and opt-out functionality for the mailings with the Optimizely Connect for Marketing Automation add-on.

The following web forms page works with the Acoustic (Silverpop) provider API and shows how you can opt in, opt out, or check the current user's status for the marketing automation add-on.

using System;
using System.Collections.Generic;
using System.Web.UI;
using EPiServer.MarketingAutomationIntegration.Caching;
using EPiServer.MarketingAutomationIntegration.Core;
using EPiServer.MarketingAutomationIntegration.Services;
using EPiServer.MarketingAutomationIntegration.Silverpop.APIs.XMLResultModel;
using EPiServer.MarketingAutomationIntegration.Silverpop.Domain;
using EPiServer.MarketingAutomationIntegration.Silverpop.Implementation;
using EPiServer.MarketingAutomationIntegration.Silverpop.Services;
using EPiServer.ServiceLocation;
    
namespace Samples
  {
    public partial class OptInOptOutSamples : Page
      {
        private SilverpopProvider _provider = WorkingContext.Current.ActiveProvider as SilverpopProvider;
        private ContactService _contactService = ServiceLocator.Current.GetInstance<IProfileService>() as ContactService;
        private ICacheService _cacheService = ServiceLocator.Current.GetInstance<ICacheService>();
     
        protected void OptOut_Click(object sender, EventArgs e)
          {
            // opt out current contact
            var contact = _contactService.GetCurrentProfile() as Contact;
    
            if (contact == null)
              {
                lblOptOutResult.Text = "Cannot get current visitor! You must create visitor first by submit a XForm to Silverpop!";
                return;
              }
    
            // need to specify recipient id to opt out exactly 1 contact in non email key database
            var response = _contactService.OptOutRecipient(contact.DatabaseId, contact.Id);
            if (response.WasSuccessful)
              {
                lblOptOutResult.Text = "Opted out current visitor successfully!";
                return;
              }
            lblOptOutResult.Text = "Failed to opt out current visitor, error: " + response.Fault.FaultString;
           }

           protected void OptIn_Click(object sender, EventArgs e)
           {
             var contact = _contactService.GetCurrentProfile() as Contact;
             if (contact == null)
               {
                 lblOptInResult.Text = "Cannot get current visitor! You must create visitor first by submit a XForm to Silverpop!";
                 return;
               }
    
             var response = _contactService.AddRecipientNonKeyed(
                              contact.DatabaseId,
                              contact.VisitorKey.Value.ToString(),
                              new List<Column>());
    
             if (response.WasSuccessful)
               {
                 lblOptInResult.Text = "Opted in current visitor successfully!";
                 return;
               }
    
             lblOptInResult.Text = "Failed to opt in current visitor, error: " + response.Fault.FaultString;
           }
    
         protected void Show_Status_Click(object sender, EventArgs e)
           {
             var contact = _contactService.GetCurrentProfile() as Contact;
             if (contact == null)
               {
                 lblStatusResult.Text = "Cannot get current visitor! You must create visitor first by submit a XForm to Silverpop!";
                 return;
               }
    
             var selectRecipientResponse = _contactService.SelectRecipientData(contact.Id, true, contact.DatabaseId);
             if (string.IsNullOrEmpty(selectRecipientResponse.OptedOut))
               {
                 lblStatusResult.Text = "Current visitor is opted in";
                }
              else
                {
                  lblStatusResult.Text = string.Format("Current visitor is opted out at: {0}", selectRecipientResponse.OptedOut);
                }
            }
       } 
  }

Related blog post: Create multiple instances of the same connector by Jason Masterson