Add Yandex Metrika integration for tracking; update FindSliderBySlugTask to ensure active slides are filtered correctly based on time; enhance app.blade.php for conditional Yandex Metrika script inclusion based on environment.

This commit is contained in:
F4ilji
2025-09-27 22:35:36 +05:00
parent 02fb2554c1
commit 72af09d93d
6 changed files with 51 additions and 16 deletions
+10 -6
View File
@@ -5,22 +5,17 @@ import 'virtual:svg-icons-register'
import { createSSRApp, h } from 'vue';
import { createInertiaApp } from '@inertiajs/vue3';
import { createInertiaApp, router } from '@inertiajs/vue3';
import { ZiggyVue } from '../../vendor/tightenco/ziggy/dist/vue.m';
import {linksReform} from "@/mixins/LinksReform.js";
import cookieMixin from "@/mixins/cookieMixin.js";
import store from '@/store/index.js';
import '@vuepic/vue-datepicker/dist/main.css';
// const appName = import.meta.env.VITE_APP_NAME || 'НТГСПИ';
createInertiaApp({
resolve: name => {
const pages = import.meta.glob('./Pages/**/*.vue')
return pages[`./Pages/${name}.vue`]()
// resolvePageComponent(`./Pages/${name}.vue`, import.meta.glob('./Pages/**/*.vue'))
},
setup({ el, App, props, plugin }) {
return createSSRApp({ render: () => h(App, props) })
@@ -37,4 +32,13 @@ createInertiaApp({
},
});
router.on('navigate', (event) => {
const metrikaId = event.detail.page.props.yandex_metrika_id;
if (metrikaId && typeof ym === 'function') {
ym(metrikaId, 'hit', window.location.href, {
title: document.title,
referer: event.detail.page.props.ziggy?.previous_url || document.referrer,
});
}
});
+26 -7
View File
@@ -6,7 +6,7 @@
@if (env('NGINX_ENV') === 'prod')
<meta http-equiv="Content-Security-Policy" content="upgrade-insecure-requests">
@endif
{{-- <title inertia>{{ config('app.name', 'Laravel') }}</title>--}}
{{-- <title inertia>{{ config('app.name', 'Laravel') }}</title>--}}
<!-- Fonts -->
<link rel="preconnect" href="https://fonts.bunny.net">
@@ -49,13 +49,32 @@
scroll-padding: 6rem;
scroll-behavior: smooth !important;
}
</style>
<body class="">
@inertia
</body>
</html>
@if(config('services.yandex_metrika.id') && app()->environment('production'))
<!-- Yandex.Metrika counter -->
<script type="text/javascript">
(function(m,e,t,r,i,k,a){
m[i]=m[i]||function(){(m[i].a=m[i].a||[]).push(arguments)};
m[i].l=1*new Date();
for (var j = 0; j < document.scripts.length; j++) {if (document.scripts[j].src === r) { return; }}
k=e.createElement(t),a=e.getElementsByTagName(t)[0],k.async=1,k.src=r,a.parentNode.insertBefore(k,a)
})(window, document,'script','https://mc.yandex.ru/metrika/tag.js', 'ym');
ym({{ config('services.yandex_metrika.id') }}, 'init', {
defer: true,
webvisor:true,
clickmap:true,
ecommerce:"dataLayer",
accurateTrackBounce:true,
trackLinks:true
});
</script>
<noscript><div><img src="https://mc.yandex.ru/watch/{{ config('services.yandex_metrika.id') }}" style="position:absolute; left:-9999px;" alt="" /></div></noscript>
<!-- /Yandex.Metrika counter -->
@endif
</body>
</html>