Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /*
- Plugin Name: Añadir el script de Google Tag Manager
- Plugin URI: http://carlosmdh.es
- Description: Plugin para insertar los Scripts de Google Tag Manager
- Version: 1.0.2
- Author: carlosmdh
- License: GPL 2+
- License URI:
- */
- //Añadir el código de Google Tag Manager en el <head>//
- add_action( 'wp_head', 'carlosmdh_google_tag_manager1' );
- function carlosmdh_google_tag_manager1() { ?>
- <!-- Google Tag Manager -->
- <script>(function(w,d,s,l,i){w[l]=w[l]||[];w[l].push({'gtm.start':
- new Date().getTime(),event:'gtm.js'});var f=d.getElementsByTagName(s)[0],
- j=d.createElement(s),dl=l!='dataLayer'?'&l='+l:'';j.async=true;j.src=
- 'https://www.googletagmanager.com/gtm.js?id='+i+dl;f.parentNode.insertBefore(j,f);
- })(window,document,'script','dataLayer','GTM-WDV8SRG');</script>
- <!-- End Google Tag Manager -->
- <?php }
- /// Añade el código de Google Tag Manager code justo antes de la de la etiqueta de cierre </body> //
- add_action( 'wp_footer', 'carlosmdh_google_tag_manager2' );
- function carlosmdh_google_tag_manager2() { ?>
- <!-- Google Tag Manager (noscript) -->
- <noscript><iframe src="https://www.googletagmanager.com/ns.html?id=GTM-WDV8SRG"
- height="0" width="0" style="display:none;visibility:hidden"></iframe></noscript>
- <!-- End Google Tag Manager (noscript) -->
- <?php }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement