Viewing 6 posts - 1 through 6 (of 6 total)
  • Author
    Posts
  • #1213542

    Hi,

    I read this post on the forum an know now that it is possible to add the Facebook pixel code to the Analytics tracking code field.
    My client has a several languages and an accordingly number of Enfold settings for each language.
    Is it true that when I paste a different code for Google Analytics and Facebook pixel in this field per language it works specificly foor that language version of the site only?

    Thanks
    Erik

    #1215683

    Hey Erik,

    Thanks for contacting us and sorry for the late reply!

    Please add following code to bottom of Functions.php file in Appearance > Editor

    //-------------------------------
    // Custom Facebook Pixel script in head section
    //-------------------------------
    
    function custom_script_name(){
    	if (get_locale() == 'en-US') {
    		?>
    		<script>
    
    		// Your script for English here
    
    		</script>
    		<?php
    	}
    	if (get_locale() == 'fr-FR') {
    	?>
    		<script>
    
    		// Your script for French here
    
    		</script>
    		<?php
    	}
    }
    add_action('wp_head', 'custom_script_name');

    Then change language codes to languages you are using and insert script.

    If you would like us to edit the file for you, please create temporary admin logins and post them here privately :)

    Best regards,
    Yigit

    #1220471

    Hi,

    Is this also the way to go for Googl analytics scripts per country?
    Or can thos be pasted in the template settings for each country?

    Thanks
    Erik

    #1220523

    Hi Erik,

    Do you mean for each language you are using on your website? If so, you can simply switch Enfold theme options language and add separate Analytics code for each language in Google Services tab.

    Alternatively, you can add following code to Functions.php file and insert your Google Analytics code

    //-------------------------------
    // Google Analytics code in head section
    //-------------------------------
    
    function custom_ga_function(){
    	if (get_locale() == 'en-US') {
    		?>
    		<script>
    
    		// Analytics code for English here
    
    		</script>
    		<?php
    	}
    	if (get_locale() == 'fr-FR') {
    	?>
    		<script>
    
    		// Analytics for French here
    
    		</script>
    		<?php
    	}
    }
    add_action('wp_head', 'custom_ga_function');

    If you would like to target per country, I think you can use plugin such as this one – https://wordpress.org/plugins/geoip-detect/ to detect your visitors country.

    Best regards,
    Yigit

    #1220550

    Thanks for the suggestion
    Will try what’s best foor my client

    Erik

    #1220654

    Hi,

    You are welcome, Erik!

    Let us know if you have any other questions or issues :)

    Best regards,
    Yigit

Viewing 6 posts - 1 through 6 (of 6 total)
  • The topic ‘Facebook pixel on WordPress with wpml and enfold’ is closed to new replies.