Skip to content
Dropsolid Help Center home page
Product documentation
Personalisation

Use Cases

In this topic we will describe certain use cases for your CDP.

Methods

In these examples we showcase what you can do with the javascript API.

Read capture BEFORE capture is saved and sent to Unomi

In this example we print the data which will be sent to Unomi:

<script>
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    window.dsdc('beforeRequest', function (data) {

        // read the capture data before script is loaded  
        console.log(data.requestData);
    });
</script>

Read & modify capture BEFORE it was saved and sent to Unomi

Remove data from capture

In this example we remove some data before sending it to Unomi:

<script>
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    window.dsdc('beforeRequest', function (data) {

        var changedCapture = data.requestData;

        // make a change, eg. remove the cookies from capture  
        changedCapture.browserData.browser.dataCookies = {};

        // use a global function to pass the modified capture back to the main script  
        dsdc.updateCapture(changedCapture);
    });
</script>

Add day of the week to capture

In this example we add some data before sending it to Unomi:

<script>
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    window.dsdc('beforeRequest', function (data) {

        var changedCapture = data.requestData;

        // make a change, eg. add the day of the week to the capture  
        var today = new Date();
        changedCapture.te__dayOfWeek = today.toLocaleDateString("en-US", { weekday: 'long' });

        // use a global function to pass the modified capture back to the main script  
        dsdc.updateCapture(changedCapture);
    });
</script>

Add birthday with date of today to capture

In this example we add some data before sending it to Unomi:

<script>
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    window.dsdc('beforeRequest', function (data) {

        var changedCapture = data.requestData;

        // make a change, eg. add today to the capture as birthday  
        changedCapture.da__birthday = (new Date()).toISOString();

        // use a global function to pass the modified capture back to the main script  
        dsdc.updateCapture(changedCapture);
    });
</script>

Read response AFTER capture is saved and sent to Unomi

In this example we read the data that was sent to Unomi:

<script>
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    window.dsdc('afterResponse', function (data) {

      // read the response data after the capture is sent to Unomi  
      console.log(data.responseData);
  });
</script>

Prevent datacaptures

Prevent all data captures

In this example we prevent all captures being sent to Unomi:

<script>
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    window.dsdc('preventCapture', true);
</script>

Prevent data captures for form submits only

In this example we prevent all form submits from being sent to Unomi:

<script>
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    window.dsdc('preventCapture', true, 'formSubmit');
</script>

Prevent all data captures on Sundays

In this example we prevent all captures from being sent to Unomi on Sundays:

<script>
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    var today = new Date();
    if (today.getDay() == 0) {
        window.dsdc('preventCapture', true);
    }
</script>

Enable the js and load events, which are prevented by default

In this example we enable certain events to be sent to Unomi which are disabled by default:

<script>
    window.dsdcSettings = window.dsdcSettings || {};
    dsdcSettings.preventCapture = dsdcSettings.preventCapture || {};

    // Set the preventCapture of these events to false  
    // This means they are no longer prevented  
    dsdcSettings.preventCapture.js = false;
    dsdcSettings.preventCapture.load = false;

    console.error(dsdcSettings);
</script>

Merging Unomi profiles based on a property

Newsletter

In this example we will set up Unomi to merge the profiles of visitors who use the same email address when subscribing to the newsletter.

Snippet

We use this snippet to check if an email field is found on the newsletter page, and if it does, it will use the email address the visitor gave in as the merge identifier for Unomi when the subscribe to the newsletter button is clicked:

<script>
    // enable namespace that handles the queue and methods
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    // merge profiles
    var getCaptureHandler = function (data) {

        // temporary store our capture data & potential merge value
        var changedCapture = data.requestData;

        // get the element of which you want to use the value to merge your Unomi profiles on
        var myMergeElement = document.getElementById("mauticform_input_newsletternl_email"); // email field on the newsletter page

        // if this element was found on the current page
        if (myMergeElement !== null && typeof myMergeElement != "undefined") {
            // get the value of this element
            myMergeValue = myMergeElement.value;

            // append the property to the capture if any found and event is a form submit
            if (myMergeValue !== null && typeof myMergeValue != "undefined" && changedCapture.event.eventData.te__activity == "form_submit") {
                // add the merge property to the capture data under the key te__mergeIdentifier_1
                changedCapture.te__mergeIdentifier_1 = myMergeValue;

                // send the changed data back to the main script
                dsdc.updateCapture(changedCapture);
            }
        }
    }

    window.dsdc('beforeRequest', getCaptureHandler);
</script>

Test

We go to the page where visitors can subscribe to the newsletter and we fill in our email address, first and last name.

We click on the subscribe to the newsletter button and then we inspect the page. In the network tab we see the capture data that was sent to Unomi and the profile it returns in response. We see our PC visitor has the profile id 61ce44a4-9063-480e-840e-afd78ec944a00 and Unomi has the email address we gave in as the merge identifier.

Next, we visit the same newsletter page on a tablet. The site does not know we are the same visitor as on the PC. We fill in our email address, first and last name.

We inspect the page before clicking on the subscribe to the newsletter button. In the network tab we see the capture data that was sent to Unomi and the profile it returns in response when we went to the newsletter page. We see our tablet visitor has the profile id b09e6b1f-2ad0-43f0-8c64-cfbaa56b625c, so Unomi views the tablet visitor as a different person.

We click on the subscribe to the newsletter button and then we inspect the page again. In the network tab we see the capture data that was sent to Unomi and the profile it returns in response. We see our tablet visitor has the profile id 61ce44a4-9063-480e-840e-afd78ec944a00 and Unomi has the email address we gave in as the merge identifier.

This means Unomi recognised a profile already exists with the same email address, so it merged the profile of the tablet visitor into the profile of the PC visitor.

The digital journey can now be continued as the same person across different devices!

Keep a score of your visitors

Keep in mind Unomi does not combine scores when profiles are merged.

Tracking targets

In this example we will set up Unomi to keep track of scoring for visitors of dxp and agency, so we can then create segments for marketeers and technical profiles to categorise the visitors.

Snippet

We use this snippet to increase or decrease the score based on the target page. If the visitor interacts (event) with a dxp page, the score for tech will increase and decrease for marketeer. If the visitor interacts (event) with an agency page, the score for marketeer will increase and decrease for tech.

<script>
    // enable namespace that handles the queue and methods
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    // enable scoring
    window.dsdc('beforeRequest', function (data) {

        // temporary store our capture data & potential merge value
        var changedCapture = data.requestData;

        // check if the visitor interacted with a dxp page
        if (changedCapture.te__target == "dxp") {
            // increase score for tech and decrease for marketeer
            changedCapture.scoring = {
                "targets": {
                    "tech": {
                        "te__operator": "+",
                        "te__value": "1"
                    },
                    "marketeer": {
                        "te__operator": "-",
                        "te__value": "1"
                    }
                }
            };
        }

        // check if the visitor interacted with an agency page
        if (changedCapture.te__target == "agency") {
            // increase score for marketeer and decrease for tech
            changedCapture.scoring = {
                "targets": {
                    "tech": {
                        "te__operator": "-",
                        "te__value": "1"
                    },
                    "marketeer": {
                        "te__operator": "+",
                        "te__value": "1"
                    }
                }
            };
        }

        // use a global function to pass the modified capture back to the main script  
        dsdc.updateCapture(changedCapture);
    });
</script>

Segment

These scoring properties will be available when creating a segment when at least one profile has the scoring properties, so we click once on the starting page of dxp in order for the scoring to get in a profile.

Now that Unomi has these scores, we can create segments to start categorising the visitors.

We start by creating a segment for marketeers. Here we add a rule which checks if the highest scoring name is marketeer, so if the score for marketeer is higher than tech in the targets group Unomi will assign this segment to the visitor.

create_segment_marketeer_part1.png

create_segment_marketeer_part2.png

We continue by creating a segment for technical profiles. Here we add a rule which checks if the highest scoring name is tech, so if the score for tech is higher than marketeer in the targets group Unomi will assign this segment to the visitor.

create_segment_tech_part1.png

create_segment_tech_part2.png

Now that we have segments for both our target groups, we can test them out.

segment_overview_marketeer_tech.png

Test

We go to an agency page and interact with the page by clicking around a few times. By inspecting the page, we see that Unomi assigned the marketeer segment to our profile.

profile_marketeer

Next, we go to a dxp page and interact with it more than we did on the agency page. By inspecting the page, we see Unomi removed the marketeer segment from our profile and assigned the tech segment instead.

profile_tech

Target groups can now get more relevant personalised content!

UTM

Tracking UTM parameters

In this example we will set up Unomi to keep track of UTM parameters in visitor profiles.

Snippet

We use this snippet to check if UTM parameters are found in the URL, and if there are, it will save them in Unomi:

<script>
    // enable namespace that handles the queue and methods
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    // track UTM parameters
    window.dsdc('beforeRequest', function (data) {

        // temporary store our capture data & potential merge value
        var changedCapture = data.requestData;

        // get query parameters in URL
        queryString = window.location.search;

        // check if URL contains query parameters
        if (queryString != '') {
            // get UTM parameters
            urlParams = new URLSearchParams(queryString);
            utmCampaign = urlParams.get('utm_campaign');
            utmSource = urlParams.get('utm_source');
            utmContent = urlParams.get('utm_content');
            utmMedium = urlParams.get('utm_medium');

            // add UTM parameters to capture data
            changedCapture.te__utmCampaign = utmCampaign;
            changedCapture.te__utmSource = utmSource;
            changedCapture.te__utmContent = utmContent;
            changedCapture.te__utmMedium = utmMedium;
        }

        // use a global function to pass the modified capture back to the main script
        dsdc.updateCapture(changedCapture);
    });
</script>

Test

We click on this link that we found on a Dropsolid post on Facebook.

dropsolid_post_on_facebook

We are redirected to a page which has these UTM parameters:

  • utm_campaign = AG-martech
  • utm_source = Facebook
  • utm_medium = social

We inspect the page and in the network tab we see the capture data that was sent to Unomi and the profile it returns in response when we went to this page. We see our visitor has the UTM parameters in the Unomi profile.

profile_utm_parameters

Now segments can be created in Unomi using these UTM parameters to better categorise visitors!

Mautic integration

These are examples of the Mautic integration feature which can be manually added to your site.

To implement these examples you need to remove a line from your Mautic tracking script to avoid sending page views twice, which looks similar to this snippet:

<script>
    (function(w,d,t,u,n,a,m){w['MauticTrackingObject']=n;
        w[n]=w[n]||function(){(w[n].q=w[n].q||[]).push(arguments)},a=d.createElement(t),
        m=d.getElementsByTagName(t)[0];a.async=1;a.src=u;m.parentNode.insertBefore(a,m)
    })(window,document,'script','http(s)://yourmautic.com/mtc.js','mt');

    // mt('send', 'pageview'); // EITHER REMOVE THIS LINE OR COMMENT IT (commented in this example)
</script>

Send Mautic ID to Unomi

We use this snippet to get the visitor's Mautic ID and send it to Unomi:

<script>
    // enable namespace that handles the queue and methods  
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    // Now BEFORE each capture happens, we'll check if we can find a Mautic ID  
    // and send it along with the capture data  

    // this is the function that looks for the ID and appends it to the capture data  
    var getMauticIdHandler = function (data) {
        // temp store our capture data & potential Mautic id  
        var changedCapture = data.requestData;

        // Get the Mautic ID value with the mtcId function that can also be used in console. (returns undefined if it doesn't exist)  
        var mauticId = window.mtcId;

        // append the ID to the capture if any found  
        if (mauticId !== null && mauticId !== undefined) {
            changedCapture.te__mautic_id = mauticId;

            // send the changed data back to the main script  
            dsdc.updateCapture(changedCapture);
        }
    }

    // This method will make sure to execute the function  
    // BEFORE each capture is saved (so for every event)  
    window.dsdc('beforeRequest', getMauticIdHandler);
</script>

Send Unomi profile segment UUIDs & human-readable names to Mautic

You need to create custom fields in Mautic to implement this example:

  • 1 for the Unomi profile segment uuids
  • 1 for the Unomi profile segment names
Human readable label Alias Publicly updatable
personalisation segment uuid personalisation_segment_u Yes
personalisation segment label personalisation_segment_l Yes

The labels and aliases seen above are examples. You can choose what label and alias you want to give your custom field. Keep in mind you will need to update the alias names in the snippet if your alias is not the same as the example.

We use this snippet to get the segment names and uuids from the visitor's Unomi profile and send them to Mautic:

<script>
    // enable namespace that handles the queue and methods  
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    // this is the function that reads the profile segment uuids and human readable names and sends them to Mautic  
    var sendToMauticHandler = function (data) {
        // create a string of all the uuids of the segments, separated by ", "  
        var segmentsUuid = data.responseData.profile.profileSegments.join(", ");

        // if the user doesn't belong to a segment, use the standard value "_unknown"  
        if (segmentsUuid == "") {
            segmentsUuid = "_unknown";
        }

        // create a string of all the names of the segments, separated by ", "  
        var segmentsNames = data.responseData.profile.profileSegmentNames.join(", ");

        // if the user doesn't belong to a segment, use the standard value "_unknown"  
        if (segmentsNames == "") {
            segmentsNames = "_unknown";
        }

        // Sending the segment uuids and the segmentNames of the profile to Mautic  
        mt('send', 'pageview', { personalisation_segment_u: segmentsUuid, personalisation_segment_l: segmentsNames });
    }

    window.dsdc('afterResponse', sendToMauticHandler);
</script>

Combination of sending Mautic ID to Unomi and Unomi profile segment UUIDs & names to Mautic

We use this snippet to get the visitor's Mautic ID and send it to Unomi, and to get the segment names and uuids from the visitor's Unomi profile and send them to Mautic:

<script>
    // enable namespace that handles the queue and methods  
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    // Now BEFORE each capture happens, we'll check if we can find a Mautic ID  
    // and send it along with the capture data  

    // this is the function that looks for the ID and appends it to the capture data  
    var getMauticIdHandler = function (data) {

        // temp store our capture data & potential Mautic id  
        var changedCapture = data.requestData;

        // Get the Mautic ID value with the mtcId function that can also be used in console. (returns undefined if it doesn't exist)  
        var mauticId = window.mtcId;

        // append the ID to the capture if any found  
        if (mauticId !== null && mauticId !== undefined) {
            changedCapture.te__mautic_id = mauticId;

            // send the changed data back to the main script  
            dsdc.updateCapture(changedCapture);
        }
    }

    // This method will make sure to execute the function  
    // BEFORE each capture is saved (so for every event)  
    window.dsdc('beforeRequest', getMauticIdHandler);

    // If you want to minimize the amount of times this is done,  
    // you can associate the Mautic retrieval with a specific event instead,  
    // eg. on script load:  
    // window.dsdc('beforeRequest', 'dom', getMauticIdHandler);  

    // this is the function that reads the profile segment uuids and human readable names and sends them to Mautic  
    var sendToMauticHandler = function (data) {
        // create a string of all the uuids of the segments, separated by ", "  
        var segmentsUuid = data.responseData.profile.profileSegments.join(", ");

        // if the user doesn't belong to a segment, use the standard value "_unknown"  
        if (segmentsUuid == "") {
            segmentsUuid = "_unknown";
        }

        // create a string of all the names of the segments, separated by ", "  
        var segmentsNames = data.responseData.profile.profileSegmentNames.join(", ");

        // if the user doesn't belong to a segment, use the standard value "_unknown"  
        if (segmentsNames == "") {
            segmentsNames = "_unknown";
        }

        // Sending the segment uuids and the segmentNames of the profile to Mautic  
        mt('send', 'pageview', { personalisation_segment_u: segmentsUuid, personalisation_segment_l: segmentsNames });
    }

    window.dsdc('afterResponse', sendToMauticHandler);
</script>

DXP

In this example we will set up Unomi to keep track of visitors visiting the DXP marketing page, so we can create a segment to categorise those visitors, which we will also send to Mautic to update their contact information.

Snippet 1

We use this snippet to set a flag when the visitor interacts with the target page:

<script>
    // enable namespace that handles the queue and methods
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    // track interaction with DXP marketing page
    window.dsdc('beforeRequest', function (data) {

        // temporary store our capture data & potential merge value
        var changedCapture = data.requestData;

        // check if the visitor interacted with the dxp marketing page
        if (changedCapture.surfing.te__pathName == "/en/dxp/dropsolid-experience-cloud-marketers") {
            // set flag
            changedCapture.bo__visitedPageDXP = true;
        }

        // use a global function to pass the modified capture back to the main script  
        dsdc.updateCapture(changedCapture);
    });
</script>

Segment

The new property will be available when creating a segment when at least one profile has the new property, so we click once on the dxp marketing page in order for the flag to get in a profile.

Now that Unomi has this flag property, we can create a segment to start categorising the visitors.

We create a segment which we name DXP. Here we add a rule which checks if the flag property is true, so if the visitor interacted with the DXP marketing page Unomi will assign this segment to the visitor.

create_segment_dxp_part1.png

create_segment_dxp_part2.png

Now that we have the segment, we can integrate Mautic so it can receive the created segment.

segment_overview_dxp.png

Snippet 2

We create the custom fields necessary in Mautic to implement this example:

  • 1 for the Unomi profile segment uuids
  • 1 for the Unomi profile segment names
Human readable label Alias Publicly updatable
personalisation segment uuid personalisation_segment_u Yes
personalisation segment label personalisation_segment_l Yes

We use this snippet to get the segment names and uuids from the visitor's Unomi profile and send them to Mautic:

<script>
    // enable namespace that handles the queue and methods  
    window.dsdc = window.dsdc || function () { (dsdc.q = dsdc.q || []).push(arguments) }; dsdc.l = +new Date;

    // this is the function that reads the profile segment uuids and human readable names and sends them to Mautic  
    var sendToMauticHandler = function (data) {
        // create a string of all the uuids of the segments, separated by ", "  
        var segmentsUuid = data.responseData.profile.profileSegments.join(", ");

        // if the user doesn't belong to a segment, use the standard value "_unknown"  
        if (segmentsUuid == "") {
            segmentsUuid = "_unknown";
        }

        // create a string of all the names of the segments, separated by ", "  
        var segmentsNames = data.responseData.profile.profileSegmentNames.join(", ");

        // if the user doesn't belong to a segment, use the standard value "_unknown"  
        if (segmentsNames == "") {
            segmentsNames = "_unknown";
        }

        // Sending the segment uuids and the segmentNames of the profile to Mautic  
        mt('send', 'pageview', { personalisation_segment_u: segmentsUuid, personalisation_segment_l: segmentsNames });
    }

    window.dsdc('afterResponse', sendToMauticHandler);
</script>

Test

We start on the dxp home page and interact with the page by clicking around a few times. By inspecting the page, we see that our Unomi profile does not have the DXP flag and therefore no segment.

profile_no_dxp

Next, we go to DXP marketing page. By inspecting the page, we see that Unomi has detected we visited the target page and assigned the DXP segment to our profile.

profile_dxp

Our contact in Mautic is also enriched by the DXP segment that it received.

People interested in DXP can now be contacted with more relevant information for their needs!

Send us your question

Do you still have unanswered questions or do you want to make some adjustments to your project? Don't hesitate to ask us your question at support@dropsolid.io or at +3293950290.