Google UTM Campaign Tracking in AMP amp-analytics - google-analytics

I am building an AMP website, and I use google analytics for tracking. However I found the utm_campaign, utm_source and utm_medium properties are not working when I migrate my site to AMP, it was working when I was using analytics.js. I tried to add ?utm_source=some_value&utm_campaign=some_value&utm_medium=some_value at the end of url, it doesn't work. I tried to add these values through extraUrlParams in the amp-analytics configuration like this: "extraUrlParams": {"utm_source": "test", "utm_campaign": "test", "utm_medium": "test"}, it doesn't work as well.

After some further digging, this problem solved. Here is how to solve the issue.
When a request comes in with ?utm_campaign=some_value&utm_medium=some_value&utm_source=some_value, it probably not the actual link amp-analytics send to GA. Actually it is sending the page_location in the amp-analytics configuration.
So if your configuration is like this: {"vars": {"gtag_id":"UA-XXXX-0", "config": {"UA-XXXX-0": {"page_title":"some_value","page_location":"$urlWithParams"}}}}, e.g. current page location is https://example.com/ , then the page_location should be like https://example.com/?utm_campaign=some_value&utm_source=some_value&utm_medium=some_value , then it will capture the UTM values. To achieve this, you can either get the current window location or url params using AMP url variables.

Related

How to create whitelisted URL pattern for Google Firebase Dynamic link?

My Dynamic link giving the error as Invalid Dynamic Link - Blocked
We could not match param 'https://www.toppscholars.com?meetingId=546546&pwd=98456' with whitelisted URL patterns in this Google project.
I tried to create whitelist which goes to playstore:
^https://play.google.com/.*id=com.appname$
Unable to use for below URL, need redirection on below url to read the values.
https://www.toppscholars.com?meetingId=546546&pwd=9845
I'm expecting the dynamic link to open my app and read the parameters.
If app not present it will go to app store / playstore.
Expecting the link to work across all the devices and platforms without error.
Issue resolved by below example.
Link: https://www.example.com/post?postId=hy48ndmFLMdxydT7mGPq
Allowlist URL Pattern: ^https{0,1}:\/\/www\.example\.com\/post([\/#\?].*){0,1}$
Similarly for
Link: https://www.toppscholars.com?meetingId=546546&pwd=9845
Allowlist URL Pattern: ^https{0,1}:\/\/www\.toppscholars\.com([\/#\?].*){0,1}$

Website with https, Google Analytics for long time with http... can I change it?

and its URL is 'secured' with SSL (with httpS://mywebsite.nl).
However, I found out that, for a long time, at Google Analytics, I use http://mywebsite.nl, ('non-secured') at my property and view's 'Default URL'.
I have two questions:
Did I miss data because I used http instead of https in the property and view's Default URL?
Can I CHANGE the http to httpS (in Google Analytics property/view) without problem, or do I lose historical data because of that? (This probably also depends on answer of Q1...) Or should I ADD a new property and/or view with https Default URL?
Thanks!
you didn't
you don't lose the historical data, feel free to change it.
That "default url" is for your convenience. you can do anything with it. That's just what GA uses to form full URLs from page paths only. Instead of using the hostname dimension there.
Also, GA is gracious enough to warn you whenever you can do significant changes to your core data.

Removing PII from URL in an SPA (GTM/GA4)

I am trying to remove Personally Identifiable Information (PII) from URLs in out Single Page Application (SPA) registered by Google Tag Manager.
The URLs have the form /customer/1234/invoice/5678, which I want to send to GA4 as /customer/(redacted)/invoice/(redacted)
What I did is the following:
In GTM, I created a Custom JavaScript variable called Page location without ids with the following content. (Note: using {{Page URL}} here, but also tried window.location.href with same effect.)
function() {
// including timestamp for debugging purposes
var url = Date.now() + {{Page URL}}.replace(/\d{4}/g, '(redacted)');
// outputting to console for debugging purposes
console.log(url);
return url;
}
In the GA4 configuration tag (which is fired on All Pages), I opened Fields to set and changed the field name page_location to {{Page location without ids}}.
I started Preview in GTM, and let GTM load the website. Tag Assistant comes up on the page, GTM reports it is connected.
Everything seems well so far:
I open the developer console on the website, and see some 20 output lines of the start page URL with timestamp, generated by my GTM script.
In GTM's Tag Assistant I can see the modified URL in both the GTM and GA4 containers, under Variables. (In the GTM container assigned to Page location without ids, in the GA4 container assigned to dl (Page Location).
In GA4, I can see the modified URL in DebugView, assigned to the page_location Parameter.
However, when I navigate to a page with ids in the URL:
The console outputs the redacted URL, good. (4 times actually, don't know why.)
However, the payload of the collect call shows the (redacted) starting page URL for the dl parameter. The actual page URL (redacted or not) is not included.
GTM show a History event logged by the GTM container with the redacted URL in the Page location without ids variable, good. The Page Path and Page URL variables however are not redacted, don't know if this is good or bad.
GTM shows for the GA4 container a Page View with the (redacted) starting page URL for the dl (Page Location) parameter!
And also GA4 in DebugView shows the starting page URL as page_location parameter.
So for some reason I am unable to push the redacted URL into the dl parameter for GA4, instead GA4 keeps on using the redacted initial (starting page) URL.
Well, no, no need really. GA4 configuration+pageview tag only needs to be called once. After that, it starts watching history changes and tracks every pageview on most SPAs. You need to only use the real page view trigger and only add more if your SPA doesn't issue history changes on navigations. But vast majority of SPA engines don't make that mistake anymore.
You should actually try implementing it and then ask your question. Update your question when you encounter non-theoretical issues and we'll help.

Google Analytics Campaign/Source/Medium Not Showing

I have a "short URL" MVC website that takes in an identifier and redirects the user to the end resource based on that identifier.
Prior to the redirect I create a web request to Google Analytics (GA) to track which identifiers are commonly used. I would also like to track some more information using campaign/source/medium options in GA but I'm having a tough time getting these to show in the reports - the link I'm using is below (utmac switched out for obvious reasons):
https://www.google-analytics.com/__utm.gif?utmdt=ShortUrl+Redirect&utmp=%2f3f20118&utmac=UA-9999999-99&utmcc=__utma%3d.1675621744.1591667140.64981.1591667140.64981.1591667140.64981.1%3b%2b&utm_source=TestSource&utm_medium=TestMedium&utm_campaign=TestCampaign
I see the hit but it shows with a medium of "(none)" and source of "(direct)" when I'm expecting to see "TestSource" / "TestMedium"... Is it that I'm constructing the URL wrong or a miss in GA setup?
I've also tried putting the utm_source/campaign/medium as part of the utmp address as query string values but no luck: https://www.google-analytics.com/__utm.gif?utmdt=ShortUrl+Redirect&utmr=0&utmp=/3f20118?utm_source=TestSource&utm_medium=TestMedium&utm_campaign=TestName&utmac=UA-9999999-99&utmcc=__utma%3d.29260146.1591743271.10202.1591743271.10202.1591743271.10202.1%3b%2b
You have to add utm parameters to the querystring of website URL.

Snowplow Analytics `uid` GET param does not appear

I have the Snowplow event tracker snippet included on my website using Google Tag Manager, and Snowplow events are indeed being sent as GET requests to the endpoint I've configured. Many of the params from the Snowplow tracker protocol are present in the requests. However, I used
window.snowplow('setUserId', 'XXXX');
in the Tag to set the uid param, but it doesn't appear in the request. How can I enable it?
The Snowplow documentation implies this event is included automatically.
Try Modify the name "snowplow_name_here" ,some words not working.
example, if your name , start with "option", don't work.

Resources