Add GTM in AMP Generatepress template
-
Hello!
I’m using the generatepress template in AMP version, however I have problems to add the Google tag manager code in the website: https://www.itbacking.com/?amp
I have tried different ways and there is no way for Google Analytics to show the traffic.
1. Manual:
I have added the two codes provided by GTM in the file: /wp-content/plugins/amp/templates/html-start.php
2. I have added the code in the functions, but it does not show it either:
add_action( ‘wp_head’, function() {
?>
<!– Google Tag Manager –>
<!– AMP Analytics –><script async custom-element=”amp-analytics” src=”https://cdn.ampproject.org/v0/amp-analytics-0.1.js”></script>
<!– End Google Tag Manager –>
<?php
} );—————————————————————–
add_action( ‘wp_body_open’, function() {
?>
<!– Google Tag Manager –>
<amp-analytics config=”https://www.googletagmanager.com/amp.json?id=GTM-XXXXX>m.url=SOURCE_URL” data-credentials=”include”></amp-analytics><?php
}, 0 );——————————————————-
3. Finally I used the following plugin, https://gist.github.com/westonruter/2ea25735be279b88c6f0946629d0240c and it doesn’t work either
Suggestions?
- The topic ‘Add GTM in AMP Generatepress template’ is closed to new replies.