When your site has a sameorigin policy, it means it only allows content to be embedded from the same origin. This can cause issues with tools like Yandex Metrica Webvisor, which may need to record interactions on your site from a different domain.
To allow Yandex Metrica Webvisor to work correctly, you need to adjust your HTTP headers to permit the necessary cross-origin requests. This can be done by modifying your .htaccess file. Specifically, you can add Webvisor's domain to the Content-Security-Policy and X-Frame-Options headers.
Here's a basic example of what you might add to your .htaccess file:
<IfModule mod_headers.c>
# Allow Yandex Metrica Webvisor
Header set Content-Security-Policy "frame-ancestors 'self' https://webvisor.com"
Header always set X-Frame-Options "ALLOW-FROM https://webvisor.com"
</IfModule>
Steps to Modify your .htaccess:
-
Backup your .htaccess file: Before making any changes, ensure you have a backup of your current .htaccess file. This allows you to restore it if anything goes wrong.
-
Access the .htaccess file: This file is typically located in the root directory of your web server. You can access it through FTP, SSH, or your web hosting control panel.
-
Add the code snippet: Use the example above and adjust the domain (https://webvisor.com) as necessary. If Webvisor uses a different or multiple domains, update the entry accordingly.
-
Save the changes: After adding the necessary header configurations, save the file.
-
Test your site: Ensure that your site and the Yandex Metrica Webvisor are functioning as expected. You may need to clear your browser cache to see the changes.
Important Considerations:
-
Testing and Validation: After making these changes, test thoroughly to ensure this configuration doesn't inadvertently cause other issues with your site's functionality or security.
-
Domain Verification: Verify the exact domains you need to allow. The example assumes https://webvisor.com, but you should confirm the exact domains used by Yandex Metrica Webvisor.
-
Security Implications: Be cautious with X-Frame-Options and Content-Security-Policy configurations. Incorrect settings can leave your site vulnerable to clickjacking or other security concerns.
-
Updates and Documentation: Ensure that you regularly update these configurations based on the latest Yandex or web security recommendations. Keep an eye on any communications or updates from Yandex regarding domain usage.
If you're uncertain about these changes or want further customization, consider consulting with a web developer familiar with server configurations and security policies.