I read the excellent post by @kenmckell on Better Bot Blocking (Part 3) and was wondering if there was a version of this implementation using Adobe Tags and the legacy App Measurement? The site we use is deployed via AEM, but does not use alloy.js / the Web SDK
Solved! Go to Solution.
Topics help categorize Community content and increase your ability to discover relevant content.
Views
Replies
Total Likes
Hi @johnanish8 ,
The hit governor function is a JS function and and can be used independently without Web SDK. The idea is to count the number of server calls sent by the device in a given time period and if that exceeds the threshold then mark the device as a bot and stop sending any more calls.
Here's how you can adapt this for your AppMeasurement implementation,
Step 1: This stays the same where you create a global rule to declare the function
To finish setting up the Action, click on the "</> Open Editor" button and copy+paste the following block of code into the code editor:
(function(){let h=globalThis.window||this;localStorage.getItem("hg_fexp")&&(new Date).getTime()>Number(localStorage.getItem("hg_fexp"))&&(localStorage.removeItem("hg_fexp"),localStorage.removeItem("hg_flag"));h.hitGovernor=function(a,c,d){a=a||60;c=c||60;d=d||60;if(localStorage.getItem("hg_flag"))localStorage.getItem("hg_flag")==="flagged"&&(a=new Date,a.setTime(a.getTime()+d*864E5),localStorage.setItem("hg_flag","1"),localStorage.setItem("hg_fexp",a.getTime().toString())),localStorage.removeItem("hg_hitt"),localStorage.removeItem("hg_hitc");else{var b=localStorage.getItem("hg_hitc")||"",e=Number(localStorage.getItem("hg_hitt"))||0;d=(new Date).getTime();b=b!==""?b.split("|").map(Number):[0,0,0,0,0];var k=b.reduce(function(f,g){return f+g},0);c=e===0?0:Math.floor((d-e)/(c/6)/1E3);e===0&&localStorage.setItem("hg_hitt",d);if(k<a) {if(c>0){if(c>5)b=[0,0,0,0,0];else for(a=0;a<c;a++)b.unshift(0),b.pop(); localStorage.setItem("hg_hitt",d)}}else localStorage.setItem("hg_flag","flagged"); b[0]++;localStorage.setItem("hg_hitc",b.join("|"));return b.reduce(function(f,g){return f+g},0)}}})();
Click on "Save" to close the editor, then click on "Keep Actions" to close the Action setup. Once you have confirmed your rule looks something like the following…
…click on "Save to Library".
Step 2: This step will change as per AppMeasurement implementation. We don't have an sendEvent complete equivalent in AppMeasurement so what you'll have to do is add an additional action after "Adobe Analytics - Sen Beacon" action in every rule that send an Adobe Analytics tracking call, below is an example using page load rule
To finish setting up the, click on the "</> Open Editor" button and copy+paste this single line of code into the code editor:
hitGovernor();
Click on "Save" to close the editor, click on "Keep Actions", then click on "Save to Library".
Step 2.5 (Optional): This also stays same, if you want to change these thresholds, you may do so by adding the following three arguments to the hitGovernor function call:
For example, if you want to flag devices that send out at least 100 server calls within an 80-second period and prevent them from sending any more server calls for at least 30 days, the code to deploy – refer to the second Tags rule above – will need to change to the following:
hitGovernor(100,80,30)
Be sure to carefully discuss and firmly establish the threshold settings - especially the hit exclusion threshold - with your team before deploying this code.
Step 3: There will be change in this step where the logic built in onBeforeSendEvent property of Web SDK Extension will be handled in s.doplugins section of Adobe Analytics Extension.
Once the AA Extension tracker custom code editor shows up, copy+paste the following line of code to anywhere in the s.doplugins function:
if(!!localStorage.getItem("hg_flag") && localStorage.getItem("hg_flag") === "1") s.abort = true;
The above logic checks for the existence of the localStorage flag (and the flag's value of “1”) before determining whether Adobe Analytics call should be aborted.
This is what s.doplugins function should look like:
Rest of the steps will stay same where you'll deploy these changes and trigger the rules.
I hope this helps.
Cheers!
Hi @johnanish8 ,
The hit governor function is a JS function and and can be used independently without Web SDK. The idea is to count the number of server calls sent by the device in a given time period and if that exceeds the threshold then mark the device as a bot and stop sending any more calls.
Here's how you can adapt this for your AppMeasurement implementation,
Step 1: This stays the same where you create a global rule to declare the function
To finish setting up the Action, click on the "</> Open Editor" button and copy+paste the following block of code into the code editor:
(function(){let h=globalThis.window||this;localStorage.getItem("hg_fexp")&&(new Date).getTime()>Number(localStorage.getItem("hg_fexp"))&&(localStorage.removeItem("hg_fexp"),localStorage.removeItem("hg_flag"));h.hitGovernor=function(a,c,d){a=a||60;c=c||60;d=d||60;if(localStorage.getItem("hg_flag"))localStorage.getItem("hg_flag")==="flagged"&&(a=new Date,a.setTime(a.getTime()+d*864E5),localStorage.setItem("hg_flag","1"),localStorage.setItem("hg_fexp",a.getTime().toString())),localStorage.removeItem("hg_hitt"),localStorage.removeItem("hg_hitc");else{var b=localStorage.getItem("hg_hitc")||"",e=Number(localStorage.getItem("hg_hitt"))||0;d=(new Date).getTime();b=b!==""?b.split("|").map(Number):[0,0,0,0,0];var k=b.reduce(function(f,g){return f+g},0);c=e===0?0:Math.floor((d-e)/(c/6)/1E3);e===0&&localStorage.setItem("hg_hitt",d);if(k<a) {if(c>0){if(c>5)b=[0,0,0,0,0];else for(a=0;a<c;a++)b.unshift(0),b.pop(); localStorage.setItem("hg_hitt",d)}}else localStorage.setItem("hg_flag","flagged"); b[0]++;localStorage.setItem("hg_hitc",b.join("|"));return b.reduce(function(f,g){return f+g},0)}}})();
Click on "Save" to close the editor, then click on "Keep Actions" to close the Action setup. Once you have confirmed your rule looks something like the following…
…click on "Save to Library".
Step 2: This step will change as per AppMeasurement implementation. We don't have an sendEvent complete equivalent in AppMeasurement so what you'll have to do is add an additional action after "Adobe Analytics - Sen Beacon" action in every rule that send an Adobe Analytics tracking call, below is an example using page load rule
To finish setting up the, click on the "</> Open Editor" button and copy+paste this single line of code into the code editor:
hitGovernor();
Click on "Save" to close the editor, click on "Keep Actions", then click on "Save to Library".
Step 2.5 (Optional): This also stays same, if you want to change these thresholds, you may do so by adding the following three arguments to the hitGovernor function call:
For example, if you want to flag devices that send out at least 100 server calls within an 80-second period and prevent them from sending any more server calls for at least 30 days, the code to deploy – refer to the second Tags rule above – will need to change to the following:
hitGovernor(100,80,30)
Be sure to carefully discuss and firmly establish the threshold settings - especially the hit exclusion threshold - with your team before deploying this code.
Step 3: There will be change in this step where the logic built in onBeforeSendEvent property of Web SDK Extension will be handled in s.doplugins section of Adobe Analytics Extension.
Once the AA Extension tracker custom code editor shows up, copy+paste the following line of code to anywhere in the s.doplugins function:
if(!!localStorage.getItem("hg_flag") && localStorage.getItem("hg_flag") === "1") s.abort = true;
The above logic checks for the existence of the localStorage flag (and the flag's value of “1”) before determining whether Adobe Analytics call should be aborted.
This is what s.doplugins function should look like:
Rest of the steps will stay same where you'll deploy these changes and trigger the rules.
I hope this helps.
Cheers!
Views
Likes
Replies
Views
Likes
Replies
Views
Likes
Replies
Views
Like
Replies
Views
Likes
Replies