How to block spam traffic from a particular source?

How to block spam traffic from a particular source?

anderags
Not applicable
2 0 4

I am getting spammed daily from adlibraryspy.com and I would like to block this, but don't know how. I saw that there was another question posted about this and marked solved, but for some reason the discussion board will not show me the question or answers to how to fix it.

Reply 1 (1)

MaxFax
Shopify Partner
13 0 3

Hi! I have the same issue. Now I am trying to block them with the Custom JavaScript. If you want to try please follow the instructions below:

 

1. Edit Your Theme Code:
• Go to your Shopify Admin.
• Navigate to Online Store > Themes.
• Click on Actions > Edit code for your current theme.
2. Add Custom Javascript:
• Open the theme.liquid file (usually located under the Layout folder).
• Add the following JavaScript code before the closing </head> tag:

 

<script type="text/javascript">
  document.addEventListener("DOMContentLoaded", function() {
    var referrer = document.referrer;
    var blockedReferrers = ["adlibraryspy.com", "app.adlibraryspy.com"];
    
    blockedReferrers.forEach(function(blockedReferrer) {
      if (referrer.includes(blockedReferrer)) {
        window.location.href = "https://yourwebsite.com/block-message"; // Replace with your desired URL or a custom block message page
      }
    });
  });
</script>

 

This script checks if the referrer is one of the blocked referrers and redirects the user if it is.

Feel free to buy me a coffee if it was helpful 😉
paypal.me/mxfax

Was my reply helpful? Buy me a coffee