Disclaimer: This website requires Please enable JavaScript in your browser settings for the best experience.

HomeDev GuideRecipesAPI Reference
Dev GuideAPI ReferenceUser GuideLegal TermsGitHubNuGetDev CommunityOptimizely AcademySubmit a ticketLog In
Dev Guide

Connect for Marketo

Connects Marketo with Optimizely Forms, letting marketers collect visitor data, and pass that on to be used with Marketo.

Prerequisites

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

Install

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

Configure

To configure your Optimizely website to use Marketo, you need a Marketo license that provides REST authentication (Endpoint URL, Client ID, and Client secret), SOAP authentication (Endpoint URL, User ID, and Encryption key), and Web tracking code.

You also must configure the connection of form fields to Marketo so that data from the specified fields can be sent to Marketo. These configurations are described in Marketo connector in the Optimizely User Guide.

See also the documentation video: Personalization with Marketo

See Marketo connector API methods how to perform operations on email templates and folders.

Encrypt credentials

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

  • MAICryptoKey – AES encryption with a 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.

Marketo connector API methods

This topic provides examples of performing operations on email templates and folders when using the Optimizely Connect for Marketo add-on with Optimizely.

Sample code for Marketo version 4 and higher

The following code shows how to perform operations on email templates and folders in Marketo version 4 and higher.

var marketoConnector = new Optimizely.Marketing.Connector.Marketo.MarketoConnector();
      marketoConnector.InstanceId = marketoConnector.Id;
    
// Get a folder by Id
var folder = marketoConnector.GetFolder(2, Optimizely.Marketing.Connector.Marketo.Services.REST.FolderType.Folder);
    
// Get a folder by name
var folderByName = marketoConnector.GetFolder("Sample folder",   Optimizely.Marketing.Connector.Marketo.Services.REST.FolderType.Folder);
    
// Get all folders
var folders = marketoConnector.GetFolders(15, 25, 2);
    
// Create a new email template
string content = System.IO.File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/SampleTemplate.html");
marketoConnector.CreateEmailTemplate("TestTemplate1", content, folder.Id, "Test Description");
    
// Get template by Id
var template = marketoConnector.GetEmailTemplate(1009);
    
// Get template by name
var templateByName = marketoConnector.GetEmailTemplate("TestTemplate1");
    
// Update Template
var isUpdated = marketoConnector.UpdateEmailTemplate(1009, "Updated Name", "Updated Description");
    
// Get template content (html of the email) by Id
var emailContent = marketoConnector.GetEmailTemplateContent(1009);
    
// Update template content (html of the email) by Id
var updateSuccess = marketoConnector.UpdateEmailTemplateContent(1009, "Updated Content");
    
// Get all templates
var allTemplates = marketoConnector.GetEmailTemplates(25);
    
// Delete a template
var delete = marketoConnector.DeleteEmailTemplate(1009);

IEmailTemplateService

public int CreateTemplate(string name, string content, int folderId, string description = "");
public bool DeleteTemplate(int id);
public EmailTemplate GetTemplateById(int id);
public EmailTemplate GetTemplateByName(string name);
public string GetTemplateContentById(int id);
public IEnumerable<EmailTemplate> GetTemplates(int maxReturn = 0);
public bool UpdateTemplate(int id, string name = "", string description = "");
public bool UpdateTemplateContentById(int id, string content);

IFolderService

public Folder GetFolderByName(string name);
public IEnumerable<Folder> GetFolders(int rootFolderId, int maxReturn = 0, int maxDepth = 0);

Sample code for Marketo version 3 and lower

The following code shows how to use the IEmailTemplateService and IFolderService methods in Marketo version 3 and lower.

using EPiServer.MarketingAutomationIntegration.Domain;
using EPiServer.MarketingAutomationIntegration.Marketo.Services;
      .
      .
      .
   EmailTemplateService emailTempService = new EmailTemplateService();
   FolderService folderService = new FolderService();
    
  // Get a folder by name
  var folder = folderService.GetFolderByName("Sample folder");
    
  // Get all folders
  var folders = folderService.GetFolders(15, 25);
      
  // Create a new email template
  string content = File.ReadAllText(AppDomain.CurrentDomain.BaseDirectory + "/SampleTemplate.html");
  emailTempService.CreateTemplate("TestTemplate1", content, folder.Id, "Test Description");
    
  // Get template by id
  var template = emailTempService.GetTemplateById(1009);
    
  // Get template by name
  var templateByName = emailTempService.GetTemplateByName("TestTemplate1");
    
  // Update Template
  var isUpdated = emailTempService.UpdateTemplate(1009, "Updated Name", "Updated Description");
    
  // Get template content (html of the email) by Id
  var emailContent = emailTempService.GetTemplateContentById(1009);
    
  // Update template content (html of the email) by Id
  var updateSuccess = emailTempService.UpdateTemplateContentById(1009, "Updated Content");
    
  // Get all templates
  var allTemplates = emailTempService.GetTemplates();
    
  // Delete a template
  var delete = emailTempService.DeleteTemplate(1009);

Related topics