With **Marketing Automation Integration 5.0.0,** you can easily create a marketing connector to get the benefits of form field mapping, form autofill integration, and visitor group integration with Optimizely Content Management System (CMS).
IMarketingConnector` interface is the main integration point to the marketing connector framework for this connector. The framework’s MarketingConnectorManager reflects over the assemblies in the site to find the `
IMarketingConnector` class implementations to use in the various CMS integrations. The `
IMarketingConnector` interface is defined as follows:
Guid Id` – The unique identifier for the connector class, which must be the same for all instances of the connector but not reused across connector classes.
Guid InstanceId` –The identifier for a connector instance that allows for multiple instances of a connector to be created with different credentials. This Id is set with the Guid from the ConnectorCredentials saved by the MarketingConnectorManager.
string Name` –The connector instance name used to identify the connector in the CMS features the Marketing Connector. This name is set with the string from the ConnectorCredentials saved by the MarketingConnectorManager.
IEnumerable<ConnectorDataSource> GetDataSources()` – Returns the ConnectorDataSources for the connector, which are used to determine where a CMS feature should submit or read data from for a connector. Typically, a ConnectorDataSource corresponds to a Database set up in a CRM product which contain different types of customer data (Accounts, Contacts, Cases, etc). ConnectorDataSources can also contain SubmissionTargets which typically correspond to Contact Lists inside a ConnectorDataSource which can be used to organize the submission to the DataSource.
IEnumerable<Field> GetDataSourceFields(long id`) – Returns all the fields for the DataSource Id. The fields can then be mapped to forms for submitting data from the form into the ConnectorDataSource.
string CreateEntity(ConnectorDataSource dataSource, Dictionary<string, string> entityFields)` – Submits the entityFields to the specified ConnectorDataSource returning the Id of the entry created.
string CreateEntity(SubmissionTarget submissionTarget, Dictionary<string, string> entityFields)`– Submits the entityFields to the specified ConnectorDataSources SubmissionTarget and returning the Id of the entry created. The Marketing Connector Framework calls this when data is submitted to a form that is mapped to one of the Marketing Connector instances.
string UpdateEntity(string entityId, ConnectorDataSource dataSource, Dictionary<string, string> entityFields`) – Updates the specified entity in the given ConnectorDataSources with the field values specified in the entityFields dictionary. The Marketing Connector Framework calls this when a submission to a mapped form occurs and the MAI cookie has an entity id value set for the ConnectorDataSource
string UpdateEntity(string entityId, SubmissionTarget submissionTarget, Dictionary<string, string> entityFields)` – Updates the specified entity in the given ConnectorDataSources’s SubmissionTarget with the field values specified in the entityFields dictionary. The Marketing Connector Framework calls this when submitting form data from a known entity where a Submission Target is configured instead of the parent ConnectorDataSources, that is, a Contact List is selected to submit to instead of a Connector Database.
EntityProfile GetEntity(ConnectorDataSource dataSource, string entityId)`– Retrieves the data for a particular EntityId in the ConnectorDataSources. The Marketing Connector Framework uses this method for CMS integrations where a particular user’s data needs to be looked at, such as VisitorGroup matching and Form Autofill scenarios.
## Activate a connector
The Marketing Connector Framework relies on the connector to call it to save credentials. Saved `
ConnectorCredentials` indicate when a `
Connector` is active and can retrieve data from its `
ConnectorDataSources`. To do this the `
MarketingConnectorManager` class has a `
SaveCredentials` method that takes a `
ConnectorCredentials` object and stores it in the system. By using this method, the Marketing Connector Framework will mark the Connector as Active and will query the Connector for data at the various CMS integration points (Forms, Visitor Group creation, etc).
The Marketing Connector Framework will not, however, test the credentials being saved. It is up to the mechanism for entering credentials to validate that the credential fields being saved can be used to connect to the external system.
After credentials are saved, the Marketing Connector Framework keeps track of configured Connector credentials to determine how many actively configured Connectors are available. However, the Marketing Connector Framework does not log in the configured account to the external system. It is up to the connector code to retrieve its configured credentials from the `
MarketingConnectorManager` classes `
GetCredentials` method and use them to log into the external system for retrieving or submitting data.
## Download sample code
Download [_SampleDoc.zip_](🔗), which contains a NuGet package and the files shown below. Install _Episerver.Marketing.Connector.Sample.1.0.0.nupkg_ to your site through Visual studio.
The code files in the NuGet package are shown in the following sections.