HomeGuidesAPI Reference
Submit Documentation FeedbackJoin Developer CommunityLog In

Connect for Marketo

The Optimizely Connect for Marketo add-on is part of Optimizely Connect for Marketing Automation, which connects Marketo with Optimizely Forms, letting marketers collect visitor data, and pass that on to be used with Marketo.

Prerequisites

An Optimizely CMS installation with Optimizely Forms, and the required Marketing Automation connector components. See [Optimizely Connect for Marketing Automation.

Installation

The Connect for Marketo MA connector is installed through the NuGet package EPiServer.MarketingAutomationIntegration.Marketo. See Platform integration compatibility for supported Optimizely versions.

Configuration

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

You also need to 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.

Encrypting 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)
  • machineKey of the server in web.config.

📘

Note

For DXP instances, use MAICryptoKey.

If you choose to use machineKey configuration, you should specify a machineKey in the web.config of your site so that when you deploy it to a different server, the same machine key is used on the new server.

📘

Note

If you neglect to specify a machineKey in the web.config, the credentials are removed when the site on the new server is accessed for the first time, in which case you need to 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.

Similarly, if the encryption uses MAICryptoKey first and then you decide to use machineKey encryption (by deleting the MAICryptoKey setting), then the credentials are deleted and must be re-entered.

Marketo connector API methods

This topic provides examples of how to perform 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


Did this page help you?