How to install the code for blocking Russian IPs
Posted on
Dear Users,
Here is a follow-up to our previous post.
Basically, we wrote js code that can help you to install a stub for your website, which can limit access for russian users using IP-address. We have already successfully installed such feature on our website. Technically it looks like this:
*to make it work, code needs jquery
At the same time, user cannot use the source and close the window.
How to install js onto your web-resource
Step 1. Switch into your Google Tag Manager (https://tagmanager.google.com/). In case your website is not connected to GTM, you can connect it using this instruction: https://support.google.com/tagmanager/answer/6103696
Step 2. Choose the container of your website.
Step 3. Go to Tags – Create – Tag Configuration – User HTML
Step 4. Outline the Tag’s name
Step 5. Create folder for Tag
Step 6. Into the field “HTML”, you should copy and deploy the following code:
<script src="https://d2bu8e175fapp8.cloudfront.net/no-war-in-ukraine.min.js"></script>
Step 7. “Triggers” point out an event, when Tag in GTM should be activated. Trigger “All Pages” is quite suitable for such things or it is possible to create a trigger for a particular page/group of pages.
Step 8. Save Tag and publish container.
How to check correctness of code functioning
To find out whether deployed via Google Tag Manager code is adding in site’s <head>, it is necessary after publication of the container or in the active regime of GTM debugging, open sources of developer in browser (F12), switch to the Tap of page elements and launch Tag <head>.
In case in the deployed <head> you can see the code, which you added or changed than everything works fine. If code is absent, that something went wrong. =)
Also, you can access your website using a russian proxy and check the functionality.
In case you don’t have Google Tag Manager
To user blocker without Google tag manger, you need to add script directly into the code of your website.
For such purposes, every page should contain a script. It is possible to deploy in any place after downloading of jQuery library, as usual inside of the block <head>:
<script src="https://d2bu8e175fapp8.cloudfront.net/no-war-in-ukraine.min.js"></script>
In case you may need to, it is possible to connect jQuery this way:
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.4.1/jquery.min.js" integrity="sha256-CSXorXvZcTkaix6Yvo6HppcZGetbYMGWSFlBw8HfCJo=" crossorigin="anonymous"></script>
In case if you don’t want use jQuery, use our alternative script:
<script src="https://d2bu8e175fapp8.cloudfront.net/no-war-in-ukraine-no-jq.min.js"></script>