
Good content takes time and effort to come up with.
Please consider supporting us by just disabling your AD BLOCKER and reloading this page again.
If your developing AMP pages for your website then adding direct Google Analytics or Other Analytics script code, it will lead to validation errors. As AMP pages don't support javascript.
But don't worry AMP has component called <amp-analytics>
tag which can be used to add not only Google Analytics but Other Analytics too.
In this article, I will show you how to integrate with Google Analytics.
Basically, to make your Analytics works you need to add the following code
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
<amp-analytics type="googleanalytics">
<script type="application/json">
{
"vars": {
"account": "GOOGLE ANALYTICS ID"
},
"triggers": {
"default pageview": {
"on": "visible",
"request": "pageview",
"vars": {
"title": "TITLE OF THE CURRENT PAGE"
}
}
}
}
</script>
</amp-analytics>
Make sure to change the GOOGLE ANALYTICS ID
& TITLE OF THE CURRENT PAGE
respectively.
The following image shows how Google Analytics ID can be found, make sure to log in to your Google Analytics account.
Hope this article helped you. Please share it with your friends.
Securely Connect Server MYSQL DB From Sequel Pro / MYSQL Workbench
Why And How To Use PHP PDO With CRUD Examples
What Is HTTP? Different HTTP Methods And Status Codes Explained With Examples
Factories To Speed Up Test-Driven Development In Laravel
Create A Composer Package? Test It Locally And Add To Packagist Repository
GitHub Login With PHP Laravel Socialite
Securely SSH Your Server & Push Files With FileZilla
Relationship Table Data With Route Model Binding In Laravel
Setup AMP (Accelerated Mobile Pages) In PHP Laravel
PHP extension ext-intl * is missing
Free Live Chat Integration Using TAWK.IO
Move Uploaded Files From Local Computer Or Server To Amazon S3 Bucket In PHP
URL Redirects From Called Functions In Laravel
Firebase Cloud Messaging (FCM) Browser Web Push Notifications Using Javascript And PHP