that's the spirit
if (this.model.name == 'Contact') {
if (this.getConfig().get('b2cMode')) {
attributes.parentType = 'Contact';
attributes.parentName = [B]this.model.get('name')[/B];
attributes.parentId = this.model.id;
<div id="iframe-container"> </div>
define('custom:views/contact/panels/matomo-user-profile', ['views/record/panels/bottom'], function (Dep) {
return Dep.extend({
template: 'custom:panels/matomo-user-profile',
afterRender: function () {
var url = "https://<removed>/index.php?date=today&module=Widgetize&action=iframe&idSite=1&period=day&moduleToWidgetize=Live&actionToWidgetize=getVisitorProfilePopup&segment=userId%3D%3D";
var api = "https://<removed>/index.php?date=today&module=API&action=index&idSite=1&period=day&method=Live.getVisitorProfile&format=JSON&expanded=1&segment=userId%3D%3D";
var email = encodeURI(encodeURI(encodeURI(this.model.get('emailAddress'))));
var xhr = new XMLHttpRequest();
if (this.model.get('emailAddress')) {
xhr.onload = function() {
if (xhr.status >= 200 && xhr.status < 300 && xhr.response != "[]") {
document.getElementById("iframe-container").innerHTML = `
<iframe style="border:none;height:100%;left:0;position:absolute;top:200px;width:100%;"
src="${url}${email}"></iframe>`;
document.getElementById("iframe-container").style.overflow = "hidden";
document.getElementById("iframe-container").style.paddingTop = "56.25%";
document.getElementById("iframe-container").style.position = "relative";
} else {
document.getElementById("iframe-container").innerHTML = "<h4>No data available for this user.</h4>"; }
}
xhr.open('GET', api + email);
xhr.send();
} else {
document.getElementById("iframe-container").innerHTML = "<h4>User has no email to track them by.</h4>";
}
},
});
});
Leave a comment: