Tag Manager

Hi you are probably really bored getting support requests about this I have seen many threads on it and looked at them all and still can;t work out how to access my Child theme code to add the tag master code.

This is not helped with my hoisting service changing from giving real time support to tickets which has been unhelpful advise to say the least. I followed there direction to get to the coder for the functions and this is the code I got :slight_smile:

<?php // ============================================================================= // FUNCTIONS.PHP // ----------------------------------------------------------------------------- // Overwrite or add your own custom functions to X in this file. // ============================================================================= // ============================================================================= // TABLE OF CONTENTS // ----------------------------------------------------------------------------- // 01. Enqueue Parent Stylesheet // 02. Additional Functions // ============================================================================= // Enqueue Parent Stylesheet // ============================================================================= add_filter( 'x_enqueue_parent_stylesheet', '__return_true' ); // Additional Functions // ============================================================================= add_post_type_support( 'page', 'excerpt' ); add_action('init', 'fix_mail_share', 999999999999); function fix_mail_share () { remove_shortcode( 'x_share' ); remove_shortcode( 'cs_share' ); remove_shortcode( 'share' ); add_shortcode( 'x_share', 'x_shortcode_share_v2' ); add_shortcode( 'cs_share', 'x_shortcode_share_v2' ); add_shortcode( 'share', 'x_shortcode_share_v2' ); } function x_shortcode_share_v2( $atts ) { extract( shortcode_atts( array( 'id' => '', 'class' => '', 'style' => '', 'title' => '', 'share_title' => '', 'facebook' => '', 'twitter' => '', 'google_plus' => '', 'linkedin' => '', 'pinterest' => '', 'reddit' => '', 'email' => '', 'email_subject' => '' ), $atts, 'x_share' ) ); $share_url = urlencode( get_permalink() ); if ( is_singular() ) { $share_url = urlencode( get_permalink() ); } else { global $wp; $share_url = urlencode( home_url( ($wp->request) ? $wp->request : '' ) ); } if ( is_singular() ) { $share_title = ( $share_title != '' ) ? esc_attr( $share_title ) : urlencode( get_the_title() ); } else { $share_title = ( $share_title != '' ) ? esc_attr( $share_title ) : urlencode( apply_filters( 'the_title', get_page( get_option( 'page_for_posts' ) )->post_title) ); } $share_source = urlencode( get_bloginfo( 'name' ) ); $share_image_info = wp_get_attachment_image_src( get_post_thumbnail_id(), 'full' ); $share_image = ( function_exists( 'x_get_featured_image_with_fallback_url' ) ) ? urlencode( x_get_featured_image_with_fallback_url() ) : urlencode( $share_image_info[0] ); if ( $linkedin == 'true' ) { $share_content = urlencode( cs_get_raw_excerpt() ); } $tooltip_attr = cs_generate_data_attributes_extra( 'tooltip', 'hover', 'bottom' ); $id = ( $id != '' ) ? 'id="' . esc_attr( $id ) . '"' : ''; $class = ( $class != '' ) ? 'x-entry-share ' . esc_attr( $class ) : 'x-entry-share'; $style = ( $style != '' ) ? 'style="' . $style . '"' : ''; $title = ( $title != '' ) ? $title : csi18n('shortcodes.share-title'); $facebook = ( $facebook == 'true' ) ? "" : ''; $twitter = ( $twitter == 'true' ) ? "" : ''; $google_plus = ( $google_plus == 'true' ) ? "" : ''; $linkedin = ( $linkedin == 'true' ) ? "" : ''; $pinterest = ( $pinterest == 'true' ) ? "" : ''; $reddit = ( $reddit == 'true' ) ? "" : ''; $email_subject = ( $email_subject != '' ) ? esc_attr( $email_subject ) : csi18n('shortcodes.share-email-subject'); $mail_to = "mailto:?subject=" . get_the_title() . "&body=" . $email_subject . " " . get_permalink() . "" ; $email = ( $email == 'true' ) ? "" : ''; $output = "
" . '

' . $title . '

' . '
' . $facebook . $twitter . $google_plus . $linkedin . $pinterest . $reddit . $email . '
' . '
'; return $output; Is this the right area to add the code ? I can;t see. anytime about header or body so not sure how to proceed ? Thanks and sorry for another request on this one !

Hi There,

Thank you for writing in! first please remove the code you showed above from your child theme’s functions.php file, it has nothing to do with Google Tag Manager

I advise you use FileZilla client for downloading and uploading the files on your site. Obviously, you need FTP credentials, if you don’t have an FTP credentials please contact your hosting and ask how you can get one.

Now, after you’ve login to your server via FTP navigate to this directory \wp-content\themes\x-child you’ll see the child theme’s functions.php file in there. Edit that file and add the following codes.

Tag Manager has two set of codes, one in the <head>

// Begin Google Tag Manager Code
// =============================================================================
function my_custom_google_tag_manager_code(){
?>

<!-- Replace this line with your Google Tag Manager Code  -->


<?php 
}
add_action( 'wp_head', 'my_custom_google_tag_manager_code' );
// End Google Tag Manager Code

And one in the <body>

// Add Google Tag Manager Code in Body
// =============================================================================
function my_custom_tag_manager_body(){
?>

<!-- Replace this line with your code provided by google -->

<?php 
}
add_action( 'x_before_site_begin', 'my_custom_tag_manager_body' );

Replace the lines <!-- Replace this line with your code provided by google --> with your actual codes.

If you have not installed a child theme yet, please follow this guide.

If this did not work, please provide us login credentials (wp-admin and FTP) in a secure note so we can take a closer look.

Cheers!

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.