Okay
  Public Ticket #335600
Google Analytics WPML in footer
Closed

Comments

  • kop started the conversation

    Hi

    I'm not sure how I should do to get my Google Analytics code on the right place. I'm using WPML and the site is in two languages, English and Swedish. I have contacted WPML and they gave me a code to enter it into the theme's footer.php.

    Is the code in the correct place?

    <?php if(!empty($options['back-to-top']) && $options['back-to-top'] == 1) { ?>

    <a id="to-top"><i></i></a>

    <?php } ?>

    <?php if(!empty($options['google-analytics'])) echo $options['google-analytics']; ?> <?php

    $gcode = "UA-1234567-02" //English

    if( 'en' != ICL_LANGUAGE_CODE ) {

    $gcode = "UA-1234567-01" //Swedish

    }

    ?>

    <script>

    (function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){

    (i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),

    m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)

    })(window,document,'script','//www.google-analytics.com/analytics.js','ga');

    /*ga('create', 'UA-1234567-01', 'auto');*/

    ga('create', '<?php echo $gcode; ?>', 'auto');

    ga('send', 'pageview');

    </script>

    <?php wp_footer(); ?>

    </body>

    </html>

  •  8,456
    Tahir replied

    Hey!

    Yes it should be alright. 

    Thanks 


    ThemeNectar Support Team 

  • kop replied

    Thanks!