Skip to content

Instantly share code, notes, and snippets.

@cinghaman
Created May 23, 2018 13:22
Show Gist options
  • Save cinghaman/6292b52bc9d1d575cf688bf0e9113221 to your computer and use it in GitHub Desktop.
Save cinghaman/6292b52bc9d1d575cf688bf0e9113221 to your computer and use it in GitHub Desktop.
WordPress Plugin Default code
<?php
/**
* Plugin Name: Scripts to Head
* Plugin URI: https://thepartytraveller.com
* Description: Add Scripts to head without any other noise
* Version: 1.0
* Author: Robin
* Author URI: https://thepartytraveller.com
*/
function as_code_to_header() {
?>
<script async src="https://www.googletagmanager.com/gtag/js?id=XX-XX-XXXX"></script>
<script>
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
gtag('config', 'XX-XXX-XX', { 'anonymize_ip': true, 'ALLOW_DISPLAY_FEATURES': FALSE });
</script>
<?php
}
add_action( 'wp_head', 'as_code_to_header' );
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment