Set the mid (ECID) value from the query string | Community
Skip to main content
February 15, 2021
Question

Set the mid (ECID) value from the query string

  • February 15, 2021
  • 1 reply
  • 1411 views

Hi All,

 

I want to set the mid value from the query string where available for example; www.test.com?mid=2345678965456546765438697054533

 

I have been testing is function in the console and I get an error "visitor is not defined" so I must not be writing it correctly.

 

(function(w) {
w.URLSearchParams = w.URLSearchParams || function(searchString) {
var self = this;
self.searchString = searchString;
self.get = function(name) {
var results = new RegExp('[\?&]' + name + '=([^&#]*)').exec(self.searchString);
if (results == null) {
return null;
} else {
return decodeURI(results[1]) || 0;
}
}
;
}
}
)(window);
var urlParams = new URLSearchParams(window.location.search);
if (urlParams.get('mid') != null)
visitor.setVisitorId(urlParams.get('mid'));

 

var urlParams = new URLSearchParams(window.location.search);

if (urlParams.get('mid') != null)

visitor.setMarketingCloudVisitorID(urlParams.get('mid'));

 

When I write _satellite.getVisitorId().getMarketingCloudVisitorID() I do get the mid value so I know it is being set.

 

I would plan to write this into Launch if successful but I am not sure what order stuff would load in.

 

Thanks in advance for any advice.

This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

1 reply

yuhuisg
Community Advisor
Community Advisor
February 19, 2021

My understanding is that ECID can't be set "externally". It is set purely from callbacks with Adobe's own API calls.