Viewing 15 posts - 1 through 15 (of 15 total)
  • Author
    Posts
  • #425666

    Hi, it´s possible to add tracking code (Google Analytics experiment ) with code block or how can I add it?

    #425860

    Hey bundy8!

    You can add Analytics code in Theme Options, if you only want it on one page it should be possible to do it within a code block element.

    Regards,
    Rikard

    #426814

    I meant addition tracking code for custom pages. It can be done by Google Tag Manager too. But thanks for answer.

    #427260

    Hi!

    Did you try the code block option and did you have any luck with it?

    Best regards,
    Rikard

    #452057

    I go try it

    #452064

    I tried code block but it is not correct. Google Analitics send me message that GA core tracking code is before GA experiment code. GA exp. code have to be before GA core code in Head section immediately after <head>. Some suggestion?

    #452201

    Hey!

    Try to use the wp_head action hook: https://codex.wordpress.org/Plugin_API/Action_Reference/wp_head

    add_action('wp_head','ava_google_analytics');
    
    function ava_google_analytics() {
         $output = "GOOGLE ANALYTICS CODE HERE";
         echo $output;
    }

    Add the is_page conditional function in order to apply it on a specific page: https://codex.wordpress.org/Function_Reference/is_page

    Cheers!
    Ismael

    #452211

    Thank you…I have found solution too. If someone wants use Google Content Experiments plugin.

    Within your theme, locate the file where the <head> tag is inserted (probably something like header.php)
    Place <?php do_action( ‘wpe_gce_head’ ); ?> right after <head>
    Save the file

    #452342

    Hi!

    Great, glad you found a solutions and thanks for sharing! :)

    Best regards,
    Rikard

    #683687

    I tried to use the Google Content Experiments plugin and added that code to the header.php file. But no code is inserted on the Page

    #683691

    Hey!

    Please refer to Ismael’s post here – https://kriesi.at/support/topic/add-tracking-code-to-custom-page/#post-452201

    Regards,
    Yigit

    #683715

    Thank you I tried

    add_action(‘wp_head’,’ava_google_analytics’);
    function ava_google_analytics() {
    if (is_page(2267)) {
    $output = “GOOGLE ANALYTICS CODE HERE”;
    echo $output;
    }
    }

    But how to replace the Goodle Analytics Code ??? There are too many “” to be masked

    #683718

    Hey!

    You can try using the code as following

    add_action('wp_head','ava_google_analytics');
    function ava_google_analytics() {
    if (is_page(2267)) {
    ?>
    YOUR CODE HERE
    <?php 
    }
    }

    Regards,
    Yigit

    #683738

    it WORKED !!! Thank you

    #683742

    Hi!

    You are welcome, let us know if you have any other questions or issues :)

    Regards,
    Yigit

Viewing 15 posts - 1 through 15 (of 15 total)
  • The topic ‘Add tracking code to custom page’ is closed to new replies.