Google AMP and Google Analytics - google-analytics

Is this the correct coding to add into my Google AMP article? I tried to submit to Google AMP and there is no error but the article will not come out in the Google Analytics when I browse my article from my handphone.
<amp-analytics type="googleanalytics">
<script type="application/json">
{
"vars": {
"account": "UA-XXXXXX"
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview",
"vars": {
"title" : "GAMP-"+ "Title of my page"
}
}
}
}
</script>
</amp-analytics>

Please refer to documentation available at
Google amp-analytics documentation
You will need to include the script reference in the head of your html document. Your whole amp html page will need to be validated as well. I suggest going through the starting documentation to create your first google-amp validated page and then add the analytics. Find that guide here
Hello World Google-amp

Related

Thumbnails not showing up after creating a post via linkedin API call

Thumbnails from external urls are not loading. However, the post inspector tool loads it just fine.
Page I used to perform some tests: https://www.cnbc.com/2022/10/28/more-than-40percent-of-us-households-will-owe-no-federal-income-tax-for-2022.html
Things I've tried so far:
Add an extra parameter at the end of the url in order to clear linkedin cache.
Post Inspector Tool
I did some research but I wasn't successful on finding a solution.
I created a post using different links like youtube and stackoverflow. Thumbnails didn't show up either.
I made sure each page has those required meta(open graph) tags that allows the crawler to retrieve information.
Here's an example of one of those API requests I've been calling to(I got this from the docs):
`
{
"author": "urn:li:person:{ID}",
"lifecycleState": "PUBLISHED",
"specificContent": {
"com.linkedin.ugc.ShareContent": {
"shareCommentary": {
"text": "Learning more about LinkedIn by reading the LinkedIn Blog!"
},
"shareMediaCategory": "ARTICLE",
"media": [
{
"status": "READY",
"description": {
"text": "Official LinkedIn Blog - Your source for insights and information about LinkedIn."
},
"originalUrl": "https://www.cnbc.com/2022/10/28/more-than-40percent-of-us-households-will-owe-no-federal-income-tax-for-2022.html",
"title": {
"text": "Official LinkedIn Blog"
}
}
]
}
},
"visibility": {
"com.linkedin.ugc.MemberNetworkVisibility": "PUBLIC"
}
}
`
In the Share Media object, you're missing the media attribute. It accepts LinkedIn URN so you'll need to upload the image. Personally, I'm not using that attribute but thumbnails that accepts image url. I don't see it in the docs anymore so something might have been changed. At least it's still working for me and I haven't seen it deprecated in the changelog yet. Be careful with the image requirements as well. It accepts an image url with this signature
{
...,
"thumbnails": [{
"url": "https://image-url.com"
}]
}

Google Analytics on AMP Story

can anyone help me to put google analytic code on amp story? Amp-story does not support GA code? I have put it like this.
<amp-analytics type="gtag" data-credentials="include">
<script type="application/json">
{
"vars" : {
"gtag_id": "G-XXXXXXXXXX",
"config" : {
"G-XXXXXXXXXX": { "groups": "default" }
}
}
}
</script>
</amp-analytics>
But it seems does not work.
Please add AMP analytic script first. Following is the google sample AMP snippet.
<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
<amp-analytics type="gtag" data-credentials="include">
<script type="application/json">
{
"vars" : {
"gtag_id": "<GA_MEASUREMENT_ID>",
"config" : {
"<GA_MEASUREMENT_ID>": { "groups": "default" }
}
}
}
</script>
</amp-analytics>
Also read following.
https://developers.google.com/analytics/devguides/collection/amp-analytics
I have got the issue. Amp Story does not support Google Analytic 4 yet. If we use UA-XXXXXXX-X this code it works but G-XXXXXXXXXX does not work.

AMP analytics - link tracking, track which links/data attributes were clicked

I have implemented AMP analytics and a couple of events, it's working fine but I'm wondering how I could capture the destination of a clicked link.
If I have a link like this:
<a rel="nofollow,noopener" data-item="ShopName" data-product="ProductName" class="link-price" target="_blank" href="ShopURL">ShopName</a>
I track it like this:
"article prices":
{
"on": "click",
"selector": ".link-price",
"request": "event",
"vars":
{
"eventCategory": "Prices",
"eventAction": "<I WOULD LIKE SHOPNAME HERE",
"eventLabel": "<I WOULD LIKE PRODUCTNAME HERE>"
}
}
I would be tempted to put some javascript in there but javascript is not allowed.
Is there any possibility to track data attributes and urls?
Use data attributes in HTML:
data-vars-my-label="ProductName1"
and your config JSON:
"vars": {
"event_label": "${myLabel}",
...
See https://github.com/ampproject/amphtml/blob/master/extensions/amp-analytics/analytics-vars.md

Tag assistant extension for AMP analytics

I tried to record a flow for my website using tag assistance extension, but it seems that it doesn't work with AMP analytics.
Could anyone help me or suggest any similar tool to do this record.
i'm trying to test if google analytics filter "to block our internal traffic" work or not. cause i tested it in google analytics and it seems that the traffic goes to the real time.
I found a solution for my problem
- we just need to send something like this
<amp-analytics type="googleanalytics">
<script type="application/json">
{
"vars": {
"account": "UA-XXXXX-Y",
"anonymizeIP": ""
},
"triggers": {
"trackPageview": {
"on": "visible",
"request": "pageview"
}
}
}
</script>
</amp-analytics>
-We should send "anonymizeIP": "" to make google pick up the user ip and then the filter will work.

Google Tag manager not registering Transactions for enhanced Ecommerce

I am running a single page checkout and the pagevies are showing fine. however the purchase transactions doesn't seem to be being processed in Google analytics.
I have the data layer up
and it seems to be registering the purchase event,
I have tag enabled with a page view on gtm.dom which has the enhanced ecommerce tag ticked,
but still nothing .
Here is the output from the Datalayer if any one can help would be really appreciative :
[
{
"ecommerce":{
"purchase":{
"actionField":{
"id":"145000010",
"revenue":295,
"tax":"0.0000",
"shipping":"5.0000",
"coupon":""
},
"products":[{
"id":"ace002",
"name":"perfume10Lt",
"price":"295.0000",
"quantity":"1.0000"
}]
},
"currencyCode":"USD"
},
"event":"purchase"
},
{
"gtm.start":1438797700099,
"event":"gtm.js"
},
{
"ecommerce":{
"impressions":0,
"promoView":0
}
},
{
"event":"gtm.dom"
},
{
"event":"gtm.load"
}
]
Added as requested by comments: The tag seems be being called at GTM.dom so i know its definitely running.
Here is the tracking tag:
Here is the image from the trigger
Change your trigger to fire the tag on the 'purchase' event instead. It may be failing because the ecommerce data layer hasn't been pushed yet before the gtm.Dom event happens.

Resources