Search code examples
adobe-analytics

how do i store a adobe marketing cloud id in an eVar


I have no tag manager legacy application. Is there a way I could write a javascript that will identify the marketing cloud ID and push it to adobe analytics as eVar? I have tried the following but it doesn't seems to be always working..

var mcloudID = s.marketingCloudVisitorID;
s.contextData['pfx.mid'] = mcloudD;

I than use processing rule to send the data to an eVar. I can see data is coming in Omniture - but I don't think it captures all the visits. Is there better way to get the marketing Cloud ID via javascript?

Thanks.


Solution

  • Here are a couple of methods you can use to get the marketing cloud visitor id.

    Method #1 - Use Marketing Cloud Visitor Methods

    Here is an example for getting the marketing cloud visitor id using the Visitor API methods:

    var visitor = Visitor.getInstance("[your mcorgid here]");
    s.contextData['pfx.mid'] = visitor.getMarketingCloudVisitorID();
    

    [your mcorgid here] - this is your company's marketing cloud organization id. It should look something like this: "016D5C175213CCA80A490D13@AdobeOrg" (do not use this id. It is an example from the documentation. You should have your own unique id assigned to your company).

    Method #2 - Use Dynamic Variable Syntax

    The Adobe Analytics (AA) library already does the work internally to get the mid value and include it as a url parameter in a given request to the collection server. Therefore you can make use of dynamic variable syntax to populate your contextData variable.

    s.contextData['pfx.mid'] = 'D=mid';
    

    Note: D= is the default prefix for dynamic variable syntax. This can be overridden to a different prefix with s.dynamicVariablePrefix so make sure to look in your code if this is set to something else.

    Method #3 - Use a Processing Rule

    You are already using a Processing Rule (PR) to map the contextData variable to a report variable (i.e. eVar or prop). Well PRs can populate variables based on query parameters in the collection url, so you can just skip the javascript coding and map mid query param directly to your eVar or prop.

    General Note about the Marketing Cloud Visitor ID

    You originally said you had tried using s.marketingCloudVisitorID but you don't always see it working. Firstly, historically I have seen from testing that s.marketingCloudVisitorID does get popped with the marketing cloud visitor id (mid). I suspect it is indeed something that was introduced into the library and we can reference it.

    However, I have not yet found any official documentation for it, so I do not recommend using it. I suspect it just slipped through the cracks for the documentation being updated, but general rule of thumb is to never trust something that is not documented to point your finger at.

    I think the real reason that you don't always see it working is because the technology itself is not 100%. There are a lot of moving parts behind this technology and a number of situations where it fails.

    For example, the MCID Service stores the MCID as a first party cookie, but it also utilizes 3rd party cookies for cross domain tracking. Visitors using certain browsers may reject 3rd party cookies by default. Or visitors could have their settings as such by choice, be it from direct browser settings (or more commonly) via browser extensions/plugins or other software that blocks ads and tracking services (e.g. uBlock). Other examples include visitors who have javascript disabled or are using older browsers that don't support the technology.

    Also, there are various fallback visitor identification methods that Adobe uses depending on those scenarios to try and preserve integrity of visitor tracking. But point is that in any of these scenarios, the mid may not be recorded.

    Overall point is that you should not expect 100% accuracy out of this, or tracking in general. Analytics has never been and never will be about 100% accuracy on an individual user basis because of the limitations of the technology vs. the war against preventing it from functioning. It will always be about looking at trends in data over time from the data you do get.