Skip to content

Instantly share code, notes, and snippets.

East Side Code EastSideCode

Block or report user

Report or block EastSideCode

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@EastSideCode
EastSideCode / scroll-add-class.js
Created Apr 10, 2018
Add a class to an element on page scroll
View scroll-add-class.js
jQuery(window).scroll(function($) {
var scroll = $(window).scrollTop();
if (scroll >= 500) {
$(".element").addClass("sample-class-to-add");
} else {
$(".element").removeClass("sample-class-to-add");
}
});
@EastSideCode
EastSideCode / functions.php
Created Apr 7, 2018
Analytics tracking for google maps directions
View functions.php
// track directions
jQuery('body').on("click", "a[href*='maps.google.com']", function(event) {
if (typeof gtag !== 'undefined') {
gtag('event', 'Click', {
'event_category': 'Contact',
@EastSideCode
EastSideCode / functions.php
Created Apr 7, 2018
Alternate contact form 7 tracking
View functions.php
jQuery(document).ajaxComplete(function() {
if (jQuery('.wpcf7-mail-sent-ok').length) {
if (typeof gtag !== 'undefined') {
gtag('event', 'Submit', {
'event_category': 'Contact Form',
'event_callback': function() {
console.log("contact form tracking sent successfully");
}
});
@EastSideCode
EastSideCode / functions.php
Created Apr 7, 2018
Analytics tracking for dynamic elements
View functions.php
jQuery(document).on('click', "a[href^='tel:']", function(event) {
if (typeof gtag !== 'undefined') {
gtag('event', 'Click', {
'event_category': 'Contact',
'event_label': 'Phone',
'event_callback': function() {
console.log("phone tracking sent successfully");
}
});
View functions.php
// for contact forms
jQuery('.quform-form').on('quform:successStart', function () {
gtag('event', 'isubmit', { 'event_category': 'Contact Forms' });
});
@EastSideCode
EastSideCode / functions.php
Created Mar 27, 2018
Grant super admin access for WordPress multisite
View functions.php
<?php
include(ABSPATH . 'wp-admin/includes/ms.php');
$user = get_userdatabylogin('YOUR_USERNAME');
grant_super_admin($user->ID);
?>
View function.php
// Disable support for comments and trackbacks in post types
function lf_disable_comments_post_types_support() {
$post_types = get_post_types();
foreach ($post_types as $post_type) {
if(post_type_supports($post_type, 'comments')) {
remove_post_type_support($post_type, 'comments');
remove_post_type_support($post_type, 'trackbacks');
}
}
@EastSideCode
EastSideCode / functions.php
Last active Feb 25, 2018
Phone and Email Link Tracking with gtag
View functions.php
// add tracking for phone call and email link clicks
function google_phone_email_clicks() { ?>
<!-- phone call tracking for analytics -->
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("a[href^='tel:']").click(function(event) {
if (typeof gtag !== 'undefined') {
gtag('event', 'Click', {
@EastSideCode
EastSideCode / functions.php
Last active Mar 8, 2018
Phone tracking using gtag
View functions.php
// add tracking for phone call clicks and contact form
function google_phone_clicks_and_contact_form() { ?>
<!-- phone call tracking for analytics -->
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("a[href^='tel:']").click(function(event) {
if (typeof gtag !== 'undefined') {
gtag('event', 'Click', {
@EastSideCode
EastSideCode / functions.php
Created Feb 20, 2018
Track phone clicks and Contact form 7 submissions
View functions.php
// add tracking for phone call clicks
function google_phone_clicks_and_contact_form() { ?>
<!-- phone call tracking for analytics -->
<script type="text/javascript">
jQuery(document).ready(function() {
jQuery("a[href^='tel:']").click(function(event){
if (typeof ga !== 'undefined') {
ga('send', 'event', 'Contact', 'Phone', 'Click');
You can’t perform that action at this time.