Skip to content

Instantly share code, notes, and snippets.

# Install dependencies
#
# * checkinstall: package the .deb
# * libpcre3, libpcre3-dev: required for HTTP rewrite module
# * zlib1g zlib1g-dbg zlib1g-dev: required for HTTP gzip module
apt-get install checkinstall libpcre3 libpcre3-dev zlib1g zlib1g-dbg zlib1g-dev && \
mkdir -p ~/sources/ && \
# Compile against OpenSSL to enable NPN
@Shoora
Shoora / ywactivitytracker.js
Last active April 7, 2024 22:22 — forked from dvygolov/ywactivitytracker.js
Script that measures interactions on your landing page. If the user is active for "checkTime" seconds - an interval is valid, if total count of valid seconds = totalTime - the goal is reached and sent to Yandex.Metrika.
class ActivityTracker {
constructor(totalTime, checkTime, metrikaId, debug = false) {
this.events = [
"touchmove",
"blur",
"focus",
"focusin",
"focusout",
"load",
"resize",
@Shoora
Shoora / admin-redirect
Created March 25, 2024 05:05 — forked from miziomon/admin-redirect
WordPress user admin redirect
/**
*
* redirect to homepage if has non "edit_posts" capabilities
*/
add_filter("admin_init", function () {
if (!current_user_can('edit_posts')) {
wp_redirect(WP_HOME);
exit;
@Shoora
Shoora / waitForYm.js
Created January 3, 2024 16:48 — forked from kernusr/waitForYm.js
Ожидание загрузки счетчика Яндекс.Метрики
/** Ожидание загрузки счетчика Яндекс.Метрики
* @param {?(number|string)} ymCounterNum - номер счетчика, если известен
* @param {function} callback - получает аргументами объект и номер счетчика
* @param {number} interval - интервал проверки готовности счетчика
*/
function waitForYm(ymCounterNum, callback, interval) {
if (!callback) return;
if (!ymCounterNum) {
let metrikaObj = (window.Ya && (window.Ya.Metrika || window.Ya.Metrika2)) || null;
ymCounterNum = (metrikaObj && metrikaObj.counters && (metrikaObj.counters() || [0])[0].id) || 0;
@Shoora
Shoora / readme.txt
Created January 3, 2024 16:44 — forked from Katia-Kovtun/readme.txt
Yandex Metrika для Opencart 2.3
Также необходимо внести правки в catalog/view/javascript/common.js
найти функцию cart.add
после if (json['success']) {
добавить sendYandexEcommerce(json, "add");
найти функцию cart.remove после success: function(json) {
добавить sendYandexEcommerce(json, "remove");
@Shoora
Shoora / gethatch.com-GA-event-widget.js
Created January 3, 2024 16:42 — forked from fewlme/gethatch.com-GA-event-widget.js
Add GA event tracking on widget retailer links
//Please ask Hatch to provide a list of all retailer IDs vs names
const retailer_mapping = {
94349 : 'MSI Store',
89105 : 'Walmart',
};
//Listener on any hatch links
document.addEventListener( "click", hatchRetailerWidgetClick );
function hatchRetailerWidgetClick(ev){
const el = ev.target;
@Shoora
Shoora / google_analytics.js
Created January 3, 2024 16:31 — forked from CGeohagan/google_analytics.js
GA4 Implementation
import VideoEvents from '@src/metrics/video_events';
import logger from '@src/shared/logger';
/**
* Custom Dimensions Map that is required for UA events with gtag
* This mapping is not required for GA4
*/
const concertCustomDimensionMap = {
'dimension1': 'video_id',
'dimension2': 'video_length',
@Shoora
Shoora / fix_Autoptimize.php
Created January 3, 2024 16:22 — forked from andxbes/fix_Autoptimize.php
Исправление lazyload Autoptimize
<?php
add_filter('autoptimize_filter_imgopt_lazyload_cssoutput', function($string) {
ob_start();
?>
<script>document.getElementsByTagName("head")[0].insertAdjacentHTML("beforeend","<?= $string ?>");</script>
<?php
return ob_get_clean();
});
@Shoora
Shoora / pmpro_add_google_tag_manager_to_head.php
Created January 3, 2024 16:12 — forked from kimcoleman/pmpro_add_google_tag_manager_to_head.php
Builds the dataLayer and loads GTM tracking in the head. Includes Custom Dimensions and Ecommerce data for Paid Memberships Pro.
<?php
/**
* Builds the dataLayer and loads GTM tracking in the head.
* Includes Custom Dimensions and Ecommerce data.
*
*/
function pmpro_add_google_tag_manager_to_head() {
global $pmpro_pages;
// Don't track admins.