Tagged: Code block, google analytics, Tracking Code
-
AuthorPosts
-
April 9, 2015 at 2:16 am #425666
Hi, it´s possible to add tracking code (Google Analytics experiment ) with code block or how can I add it?
April 9, 2015 at 12:28 pm #425860Hey 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,
RikardApril 10, 2015 at 10:48 pm #426814I meant addition tracking code for custom pages. It can be done by Google Tag Manager too. But thanks for answer.
April 13, 2015 at 4:03 am #427260Hi!
Did you try the code block option and did you have any luck with it?
Best regards,
RikardMay 30, 2015 at 6:37 pm #452057I go try it
May 30, 2015 at 7:42 pm #452064I 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?
May 31, 2015 at 8:05 am #452201Hey!
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!
IsmaelMay 31, 2015 at 8:56 am #452211Thank 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 fileJune 1, 2015 at 6:56 am #452342Hi!
Great, glad you found a solutions and thanks for sharing! :)
Best regards,
RikardSeptember 8, 2016 at 1:31 pm #683687I 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
September 8, 2016 at 1:41 pm #683691Hey!
Please refer to Ismael’s post here – https://kriesi.at/support/topic/add-tracking-code-to-custom-page/#post-452201
Regards,
YigitSeptember 8, 2016 at 2:32 pm #683715Thank 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
September 8, 2016 at 2:37 pm #683718Hey!
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,
YigitSeptember 8, 2016 at 3:08 pm #683738it WORKED !!! Thank you
September 8, 2016 at 3:17 pm #683742 -
AuthorPosts
- The topic ‘Add tracking code to custom page’ is closed to new replies.