Hi all, I have a situation where the activity map is being trigger when a visitor interacts with the navigation menu. ie menu opening up / showing sub menus. These are the links which have the following href="javascript:void(0);"
I would simply want to abort or cancel "sendEvent" requests programmatically (using example code snippets below). Now, the problem is that if you use something like the below in the callback, it results in rather ugly console log - example below. Could someone suggest a clean cut solution ? I know that ideally adobe would need to fix this issue, but I don't want to wait till it is done.
if (/^javascript:/.test(content.linkUrl)) {
reject("Operation aborted");
}
// OR
if (/^javascript:/.test(content.linkUrl)) {
throw new Error("javascript: url");
}
Console error - using reject();
Solved! Go to Solution.
Views
Replies
Total Likes
@Parvesh_Parmar thanks for the above.
The Web SDK configuration variable clickCollectionEnabled handles the automatic collection of Activity Map data. It is enabled by default unless explicitly disabled.
alloy("configure", { datastreamId: "ebebf826-a01f-4458-8cec-ef61de241c93", orgId: "ADB3LETTERSANDNUMBERS@AdobeOrg", clickCollectionEnabled: true });
So, any links (internal and external) will be tracked by default. The clickCollection can be configured further - clickCollection | Adobe Data Collection.
In any case, I have found a very simple (and quite elegant solution). All you have to do is to reset the "content" in the click properties callback. This eliminates the console.log ever and prevents the data from being sent (default alloy.js configuration).
Quite happy, as I have fully working and fairly configurable activity map solution in place !
Hello @Franc_G ,
If I understand correctly, the issue is that when a user interacts with the navigation menu (e.g., opening/closing submenus with links that have href="javascript:void(0);"
), it triggers unnecessary sendEvent
requests in AEP. You’re trying to abort or cancel these events programmatically, but using methods like reject()
or throw new Error()
results in unwanted error messages in the console.
I’ve reviewed the following documentation:
https://experienceleague.adobe.com/en/docs/experience-platform/web-sdk/commands/sendevent/overview
However, I'm not entirely sure how the sendEvent
function is configured on your end. If it’s triggered by a click event, this issue can likely be resolved by managing the click event and preventing the sendEvent
from being triggered unnecessarily.
Here’s a potential solution:
function handleClickEvent(content) {
// Check if the linkUrl matches 'javascript:void(0);'
if (/^javascript:void\(0\)/.test(content.linkUrl)) {
// If the condition is met, simply return without sending the event
return;
}
// If condition is not met, proceed to send the event
alloy("sendEvent", {
xdm: {
eventType: "click",
web: {
webInteraction: {
name: content.linkName,
URL: content.linkUrl,
},
},
},
}).catch((error) => {
console.error("Error while sending event:", error);
});
}
This approach handles the click event by checking if the href
is javascript:void(0);
. If it is, the function exits early, preventing the sendEvent
from firing. Otherwise, the event is sent as expected.
Hope it will help you.
Kr,
Parvesh
@Parvesh_Parmar thanks for the above.
The Web SDK configuration variable clickCollectionEnabled handles the automatic collection of Activity Map data. It is enabled by default unless explicitly disabled.
alloy("configure", { datastreamId: "ebebf826-a01f-4458-8cec-ef61de241c93", orgId: "ADB3LETTERSANDNUMBERS@AdobeOrg", clickCollectionEnabled: true });
So, any links (internal and external) will be tracked by default. The clickCollection can be configured further - clickCollection | Adobe Data Collection.
In any case, I have found a very simple (and quite elegant solution). All you have to do is to reset the "content" in the click properties callback. This eliminates the console.log ever and prevents the data from being sent (default alloy.js configuration).
Quite happy, as I have fully working and fairly configurable activity map solution in place !
Views
Likes
Replies
Views
Likes
Replies