Home Forums WoodMart support forum Google Anlitics – How to add it without a plugin?

Google Anlitics – How to add it without a plugin?

Viewing 8 posts - 1 through 8 (of 8 total)
  • Author
    Posts
  • #530534

    Matimti
    Participant

    How do I add Google Analytics to my Woodmart store? I wanted to do it without adding unnecessary plugins and in a way that would allow me to easily add various tags for conversion measurements in the future.

    #530669

    Hung Pham
    Keymaster

    Hi Matimti,

    Thanks for reaching to us.

    Unfortunately, there is no such option in Theme Settings.

    The best way to add the Google Analytics code is by using this free plugin Insert Headers and Footers, have a look at the site
    https://wordpress.org/plugins/insert-headers-and-footers/

    Regards,

    #530708

    Matimti
    Participant

    I wonder if it is possible to add such code to a child theme? Earlier, I gave up the snipet code plugin in favor of moving the codes to a child theme. I have mixed feelings about installing another plugin 😛

    #530713

    Hung Pham
    Keymaster

    Hi Matimti,

    Please try to add to functions.php file in Child theme.

    function child_google_analytics() {
    	?>
    	<!-- Paste your Google Analytics code here and remove this message -->
    	<?php
    }
    add_action('wp_head', 'child_google_analytics');

    Regards,

    #530724

    Matimti
    Participant

    Thank you very much. Would you be able to create such code for the “body” section?
    Below is the information from Google Tag Manager:

    “Additionally, paste this code immediately after the opening <body> tag:”

    #530746

    Hung Pham
    Keymaster

    Hi Matimti,

    Please remove previous code try to add to functions.php file in Child theme.

    function child_google_analytics() {
    	?>
    	<!-- Paste your Google Analytics code here and remove this message -->
    	<?php
    }
    add_action('wp_body_open', 'child_google_analytics');

    Regards,

    #530764

    Matimti
    Participant

    Thank you! Can I paste both codes because I have a tag for the head and body sections? I didn’t express myself precisely earlier.

    #530775

    Hung Pham
    Keymaster

    Hi Matimti,

    Yes you can, but need to change function name first, for e.g:

    function child_google_analytics1() {
    	?>
    	<!-- Paste your Google Analytics code here and remove this message -->
    	<?php
    }
    add_action('wp_body_open', 'child_google_analytics1');
    
    function child_google_analytics() {
    	?>
    	<!-- Paste your Google Analytics code here and remove this message -->
    	<?php
    }
    add_action('wp_head', 'child_google_analytics');

    Regards,

Viewing 8 posts - 1 through 8 (of 8 total)