Get Code : Manual Comms Preference Update
Prerequisites
Initial setup
-
Add the following code to your hosted webpage. The MSPI Analytics tag should be added near the top of the head tag and before any other script or CSS tags.
-
Activity will be captured immediately as triggers data starts flowing.
<script>
(function (a, t, i) { var e = "MSEI"; var s = "Analytics"; var o = e + "queue"; a[o] = a[o] || []; var r = a[e] || function (n) { var t = {}; t[s] = {}; function e(e) { while (e.length) { var r = e.pop(); t[s][r] = function (e) { return function () { a[o].push([e, n, arguments]) } }(r) } } var r = "track"; var i = "set"; e([r + "Event", r + "View", r + "Action", i + "Property", i + "User", "initialize", "teardown"]); return t }(i.name); var n = i.name; if (!a[e]) { a[n] = r[s]; a[o].push(["new", n]); setTimeout(function () { var e = "script"; var r = t.createElement(e); r.async = 1; r.src = i.src; var n = t.getElementsByTagName(e)[0]; n.parentNode.insertBefore(r, n) }, 1) } else { a[n] = new r[s] } if (i.user) { a[n].setUser(i.user) } if (i.props) { for (var c in i.props) { a[n].setProperty(c, i.props[c]) } } a[n].initialize(i.cfg) })(window, document, {
src: "https://download.pi.dynamics.com/sdk/web/msei-0.js",
name: "msdynmkt",
cfg: {
ingestionKey:"9bef69e7e88e48c1a83f7c18c639e1d5-dcbe4911-3ae1-4c39-b6f5-9eeadda8c5af-6780"
}
});
</script>
Integrate
-
Track a trigger
-
Copy the below code snippet(s) and integrate it with your system
-
Replace <customer-id> with a profile identifier from Audience Insights. The identifier can be an ID or any attribute that is defined as a primary or alternate ID in Audience Insights.NOTE: when using alternate IDs to identify customers, the system may return multiple results. Should that be the case, the trigger will be dropped and not processed in journeys.
var _customer-id = ""; // Function to get User Details function getUserDetails() { var Email = $("#Lemail").val(); webapi.safeAjax({ type: "GET", url: "/_api/contacts?$filter=emailaddress1 eq '" + Email + "'", contentType: "application/json", //data: JSON.stringify(recordObj), success: function (data) { _customer-id = data.value[0].contactid console.log(_customer-id) }, error: function (res, status, xhr) { ; } }); }, function track_msdynmkt_manualcommspreferenceupdate_211228920() { window["msdynmkt"].setUser({ authId: "<_customer-id>"}); //primary or alternate customer ID - see instructions window["msdynmkt"].trackEvent({ name: "msdynmkt_manualcommspreferenceupdate_211228920", //Trigger title: Manual Comms Preference Update ingestionKey : "9bef69e7e88e48c1a83f7c18c639e1d5-dcbe4911-3ae1-4c39-b6f5-9eeadda8c5af-6780", version: "1.0.0" , properties: { "bindingid" : "<replace-with-string-type-value>", "contactpoint_email" : "<replace-with-email>", "contactpoint_phone" : "<replace-with-phone>" } }); }
-
The following types are supported for trigger properties:
- Text
- Number
- True or false
- Date/Time
- Entity reference
Prerequisites
- Download the Sdk.
-
Unzip the compressed file ei-csharp-sdk.zip to a local folder.
-
Add the local folder where you put the SDK as a new Nuget Package Source.
- Install EngagementInsights package to your project.
-
Add reference of engagement insights on your page
using Microsoft.EngagementInsights;
-
Initialize the SDK
Analytics analytics = new Analytics("9bef69e7e88e48c1a83f7c18c639e1d5-dcbe4911-3ae1-4c39-b6f5-9eeadda8c5af-6780");
Integrate
-
Track a trigger
-
Copy the below code snippet(s) and integrate it with your system
-
Replace <customer-id> with a profile identifier from Audience Insights. The identifier can be an ID or any attribute that is defined as a primary or alternate ID in Audience Insights.NOTE: when using alternate IDs to identify customers, the system may return multiple results. Should that be the case, the trigger will be dropped and not processed in journeys.
////primary or alternate customer ID - see instructions User user = new User() { UserAuthId = "<_customer-id>" }; analytics.SetUser(user); ////Trigger title: Manual Comms Preference Update Event sampleEvent = new Event("msdynmkt_manualcommspreferenceupdate_211228920"); sampleEvent.SetProperty("bindingid", "<replace-with-string-type-value>"); sampleEvent.SetProperty("contactpoint_email", "<replace-with-email>"); sampleEvent.SetProperty("contactpoint_phone", "<replace-with-phone>"); analytics.TrackEvent(sampleEvent); analytics.UploadNow();
-
The following types are supported for trigger properties:
- Text
- Number
- True or false
- Date/Time
- Entity reference
Prerequisites
- ( e.g Xcode 8+ )
- iOS 8.2+
- Download sdk.
-
Place the `EIObjC.xcframework` file in the `Frameworks` folder.If a `Frameworks` folder does not exist already create one in the project folder
-
Open your project in Xcode, and navigate to the 'General' settings. Add the `EIObjC.xcframework` to the project under the 'Frameworks, Libraries, and Embedded Content' section.
-
Import the framework header file in AppDelegate.m with the following code:
#import <EIObjC/EIObjC.h>
-
Initialize the SDK from application:didFinishLaunchingWithOptions:
Please set the 'ingestionKey' field in the EIConfig.plist file with your unique ingestion key
NSError *error = [NSError new]; id<EIIAnalytics> analytics = [EIAnalyticsProvider analyticsForIngestionKey:@"9bef69e7e88e48c1a83f7c18c639e1d5-dcbe4911-3ae1-4c39-b6f5-9eeadda8c5af-6780" error:&error];
Integrate
-
Track a trigger
-
Copy the below code snippet(s) and integrate it with your system
-
Replace <customer-id> with a profile identifier from Audience Insights. The identifier can be an ID or any attribute that is defined as a primary or alternate ID in Audience Insights.NOTE: when using alternate IDs to identify customers, the system may return multiple results. Should that be the case, the trigger will be dropped and not processed in journeys.
EIUser *user = [EIUser new]; user.authId = @"<_customer-id>"; //primary or alternate customer ID - see instructions [analytics setUser:user]; EIEvent *event = [EIEvent new]; event.name = @"msdynmkt_manualcommspreferenceupdate_211228920"; //Trigger title: Manual Comms Preference Update [event setValue:@""<replace-with-string-type-value>"" forKey:@"bindingid"]; [event setValue:@""<replace-with-email>"" forKey:@"contactpoint_email"]; [event setValue:@""<replace-with-phone>"" forKey:@"contactpoint_phone"]; [analytics trackEvent:event];
-
The following types are supported for trigger properties:
- Text
- Number
- True or false
- Date/Time
- Entity reference
Prerequisites
- ( e.g Android Studio )
- Minimum Android API Level: 16 (Jelly Bean)
- Download the android SDK
-
Place the eiandroidsdk-debug.aar file in the libs folder.
-
Open your Android application in Android Studio.
-
Open your project level build.gradle file and add the following snippets:
dependencies { implementation(name: 'eiandroidsdk-debug', ext: 'aar') api 'com.google.code.gson:gson:2.8.1' } repositories { flatDir { dirs 'libs' } }
-
Set up the engagement insights SDK configuration through your AndroidManifest.xml file located under the manifests folder. Add the following lines under your <application> tag
<provider android:authorities="${applicationId}.com.microsoft.engagementinsights.AnalyticsContentProvider" android:name="com.microsoft.engagementinsights.AnalyticsContentProvider" /> <meta-data android:name="com.microsoft.engagementinsights.ingestionKey" android:value="'9bef69e7e88e48c1a83f7c18c639e1d5-dcbe4911-3ae1-4c39-b6f5-9eeadda8c5af-6780'" />
-
Initialize the engagement insights SDK from your MainActivity
Java
Analytics analytics = new Analytics();
Kotlin
var analytics = Analytics()
Integrate
-
Track a trigger
-
Copy the below code snippet(s) and integrate it with your system
-
Replace <customer-id> with a profile identifier from Audience Insights. The identifier can be an ID or any attribute that is defined as a primary or alternate ID in Audience Insights.NOTE: when using alternate IDs to identify customers, the system may return multiple results. Should that be the case, the trigger will be dropped and not processed in journeys.
Java
User user = new User(); user.setAuthId(<_customer-id>); //primary or alternate customer ID - see instructions analytics.setUser(user); Event sampleEvent = new Event("msdynmkt_manualcommspreferenceupdate_211228920"); //Trigger title: Manual Comms Preference Update sampleEvent.setProperty("bindingid", "<replace-with-string-type-value>"); sampleEvent.setProperty("contactpoint_email", "<replace-with-email>"); sampleEvent.setProperty("contactpoint_phone", "<replace-with-phone>"); analytics.trackEvent(sampleEvent);
Kotlin
var user = User(); user.setAuthId(<_customer-id>); //primary or alternate customer ID - see instructions analytics.setUser(user); var sampleEvent = Event("msdynmkt_manualcommspreferenceupdate_211228920"); //Trigger title: Manual Comms Preference Update sampleEvent.setProperty("bindingid", "<replace-with-string-type-value>"); sampleEvent.setProperty("contactpoint_email", "<replace-with-email>"); sampleEvent.setProperty("contactpoint_phone", "<replace-with-phone>"); analytics.trackEvent(sampleEvent);
-
The following types are supported for trigger properties:
- Text
- Number
- True or false
- Date/Time
- Entity reference
Prerequisites
- Download Python sdk , Extract sdk and copy ei_analytics-2.0.3.491.egg file from pi_analytics folder
-
To install the sdk run `python -m easy_install ei_analytics-2.0.3.491.egg` or place ei_analytics-2.0.3.491.egg file somewhere it can be accessed by your program. Then, to import use the following code
import sys sys.path.append('/path/to/ei_analytics-2.0.3.491.egg')
-
Initialize log manager
from ei_analytics import Analytics, Event, User from engagement_insights import LogManager tenant_key = '9bef69e7e88e48c1a83f7c18c639e1d5-dcbe4911-3ae1-4c39-b6f5-9eeadda8c5af-6780' LogManager.initialize(tenant_key) eia = Analytics(tenant_key)
Integrate
-
Track a trigger
-
Copy the below code snippet(s) and integrate it with your system
-
Replace <customer-id> with a profile identifier from Audience Insights. The identifier can be an ID or any attribute that is defined as a primary or alternate ID in Audience Insights.NOTE: when using alternate IDs to identify customers, the system may return multiple results. Should that be the case, the trigger will be dropped and not processed in journeys.
global eia #primary or alternate customer ID - see instructions user = User(auth_id='<_customer-id>') eia.set_user(user) #Trigger title: Manual Comms Preference Update sampleEvent = Event('msdynmkt_manualcommspreferenceupdate_211228920') sampleEvent.set_property("bindingid", "<replace-with-string-type-value>") sampleEvent.set_property("contactpoint_email", "<replace-with-email>") sampleEvent.set_property("contactpoint_phone", "<replace-with-phone>") eia.track_event(sampleEvent)
-
The following types are supported for trigger properties:
- Text
- Number
- True or false
- Date/Time
- Entity reference
-
Flushing trigger pipeline and shutting down
LogManager.flush_and_tear_down()