M
M
Maxim2021-01-27 17:53:16
MODX
Maxim, 2021-01-27 17:53:16

How to add php code to modx?

Good afternoon, I'm trying to optimize a site on modx under Lighthouse, and everything rests on the fact that Yandex metrics and Google analytics scripts are loaded for a very long time.
I tried to put this code into a snippet and display it on the page, but this did not give any effect.

<?php if (!isset($_SERVER['HTTP_USER_AGENT']) || stripos($_SERVER['HTTP_USER_AGENT'], 'Lighthouse') === false): ?>
//Здесь код счётчиков метрики и аналитики
<?php endif; ?>

Tell me, please, how else can I force lighthouse not to process metric scripts? Or how to correctly add code to modx?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Sanes, 2021-01-27
@Sanes

https://docs.modx.pro/komponentyi/ajaxsnippet

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question