I have two domains mysite.com and mysite.cz and I want to see traffic sources for both domains, which i currently can't as i am tracking only ".com" domain. Any ideas how to achieve that?
You need to implement cross-domain tracking between the two sites, which isn't trivial. There's good advice here:
Google Analytics Cross Domain Tracking and _setDomainName()
In addition to s6mike you can also implement the Cross-Domain Auto Linking plugin:
To simplify the cross domain linking proces say you have a website hosted on source.com that you want to track with cross domain tracking:
destination.com
test.destination.com/page2
test.dest3.com?page4
Code
//Load the plugin.
ga('require', 'linker');
Define domains
// Define which domains to autoLink.
ga('linker:autoLink', ['destination.com', 'dest3.com']);
or define with regular expression
// Define which domains to autoLink using a regular expression.
ga('linker:autoLink', [/^example\.(com|net)$/]);
set allowLinker configuration parameter to true
ga('create', 'UA-XXXXXX-X', 'auto', {
'allowLinker': true
});
resource
https://developers.google.com/analytics/devguides/collection/analyticsjs/cross-domain#autolink
EDIT
Once you have domain linking established, you will see only the request URI in the content reports, and not the top-level or sub-domain for a given page.
Set up a master view (profile) for your primary domain without filters.
Create a view (profile) especially for cross-domain tracking and re-use master tracking code
View (Profile) Settings page -> Add Filter link
Add New Filter
Custom Filter -> Filter type settings: Advanced
FieldA to Hostname & FieldB to Request URI
Set the values for both Field A and Field B to (.*)
Set the Output To --> Constructor option to Request URI: $A1$B1
Your reports will now show:
example.com/index.php
example.net/more.php
example.cz/more.php
resource
https://developers.google.com/analytics/devguides/collection/gajs/gaTrackingSite?csw=1#keyComponents
Related
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.
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.
I am developing a static site using gatsby.js. I need to set up a redirect test using Google Optimize. I created the redirect test at https://optimize.google.com and started it. After that, I used this code to set up the redirect tests in the site:
gtag('config', 'UA-48341628-1', {'optimize_id': 'GTM-XXXXXX'});
gtag('set', {'expId': 'xxxxxxxxxxxxxxxxxxxxxx'});
gtag('set', {'expVar':'New Signup Page'});
The purpose of the test is to redirect some people from /signup to /sign-up. But when I am going to /signup nothing happens even if I am setting 0 weight to /signup and 100% weight to /sign-up. What am I doing wrong?
My Google Optimize setup:
Based on the Analytics field-reference, the Experiment Variation must be provided as the index of the selected variation, not by its name. So in your case:
gtag('set', {'expVar':'1'});
The problem existed as I've tried to use localhost as the base URL which has not been recognized by Google Optimize. I've solved the problem by using http://test.io as the base URL and have added it to my /etc/hosts mapped to 127.0.0.1.
Say I have a website where the main page is mydomain.com/
Then I have a shop subdomain where the main page of the shop is shop.mydomain.com/
I have set up cross domain tracking and that's working fine. I'm a bit confused about how to track the following as a funnel:
mydomain.com/ -> shop.mydomain.com/
Since the funnel setup doesn't consider the domain and the path is both /, wouldn't GA see this as the same page?
If you'd like to see the domain name as well as the Request URI in your reports, create an Advanced filter for your view with the following settings:
Filter Type: Custom filter > Advanced
Field A: Hostname
Extract A: (.*)
Field B: Request URI
Extract B: (.*)
Output To: Request URI
Constructor: $A1$B1
Source
I am trying to implement google analytics with outbound clicks tracking using Google Tag Manager. I have the following tags set:
Google Analytics Universal - Page View - Firing rules: All pages
All Clicks - Link Click Listener - Firing rules: All pages
External Links Tracker - Universal Analytics - Event - Firing rules:
External link
The external link rule is defined as follows:
{{event}} equals gtm.linkClick
{{element url }} does not start with http://example.com
{{element url }} does not start with http://www.example.com
When I run the GTM in debug it seems to be working but when I publish it, it does not work. Analytics only collects the normal traffic but no events for outbound clicks.
Any ideas?
checklist,
I think the answer is quite simple - you have to create two rules, because if you include both conditions (with WWW and without WWW), you have to consider the operator being used. GTM in using using AND operator by default, so this tag would fire if both of the conditions would be matched AT the same time. Which will never happen :)
To avoid a situation when you URL is in {{element url}} (as a parameter), creating a simple rule with regular expression should do the trick:
Rule 1) Outbound WWW
{{event}} equals gtm.linkClick
{{element url }} does not match RegEx ^http:\/\/([a-z]*\.)?example\.com
Try {{element url}} does not contain example.com
What about:
{{element url}} does not match regex ^http://(www\.)?example\.com