I've got an email campaign that Im trying to track with Google Analytics, but for some reason the source, campaign etc are not being tracked.
The URL I'm using is:
https://makemeacocktail.com/list/14911/wimbledon-cocktails/?utm_source=mailinglist&utm_campaign=weeklynewsletter&utm_term=wimbledon
I've obviously got some htaccess rules kicking in that change the php _GET variables, but that shouldn't really matter here (I dont think).
My GA tracking code is:
const dimensions = {
TRACKING_VERSION: 'dimension1',
CLIENT_ID: 'dimension2',
};
const TRACKING_VERSION = '1';
ga('create', 'UA-22275118-1', 'auto');
ga('set', 'transport', 'beacon');
ga('set', dimensions.TRACKING_VERSION, TRACKING_VERSION);
ga('send', 'pageview');
ga((tracker) => {
var clientId = tracker.get('clientId');
tracker.set(dimensions.CLIENT_ID, clientId);
});
and passing the GA script through using:
<script async src="https://www.google-analytics.com/analytics.js"></script>
(This can all be seen in the source). Am I doing something fundamentally wrong?
Thanks in advance
Here are a few thoughts to troubleshoot this:
Install the Google Analytics Debugger in Chrome and verify your pageview is triggering when the campaign URL is there. You'll be able to see individual dimensions and metrics too (so you can check you custom dimensions too).
It seems like you're implying that the pageviews are working, but I wanted to include this just for due diligence.
Looks like you're relying on ES6 and the beacon to send data. That should be fine, but if your users are on older browsers that may prevent the data from coming through.
UTM campaigns require a utm_campaign, utm_source, and utm_medium to be valid. This does not prevent them from sending, but I'd recommend updating your campaign URLs if possible (you're missing utm_medium).
Are you using a filtered view? If so, your own traffic won't appear in the reports.
Are you using the Real Time reports? If not, you'll need to wait a few hours before the data becomes available in the Google Analytics standard reports.
Hopefully one of those steps gets you pointed in the right direction. Best of luck!
Edit: Viewing the source of that link you provided, I don't see your Google Analytics snippet in there. Maybe you're working on it now, but try viewing the page in an incognito window and check the source (maybe your script is tied to an admin or dev user?).
Related
I've got myself a bit of a head scratcher here, for me anyway, as I'm a bit new to all this.
I have WP a site that has its GA snippet inserted with Google Site Kit.
There is a plugin that, when a user registers, sets the users ID to a custom dimension.
The code to execute this 'set' has been added to the WP footer with the add_action('wp_footer') command.
The code looks like this:
<script type=\"text/javascript\" id=\"set-google-id-dimension\">
document.addEventListener(\"readystatechange\", event => {
if (event.target.readyState === \"complete\") {
try{
gtag('event', 'registration', {'dimension1': '".$client."'});
}catch(e){
try{
ga(function() {
// Logs an array of all tracker objects
var trackers = ga.getAll();
var firstTracker = trackers[0];
console.log('tracker: '+firstTracker.get('name'));
ga(firstTracker.get('name')+\".set\",\"dimension1\" ,\"".$client."\");
});
}catch(e){
console.log('GA and GTAG not defined');
}
}
}
});
</script>
For ease of reading, I've stripped out the PHP, but this is being echoed out in the footer.
Why the GTAG and GA command? Both analytics are being output in the console, though the site owner does not know why as "they only use Google Site Kit".
Now, this code works on the dev site that I control (and I've set it up to mimic the live site as best as possible):
However, when on the "live" site, the dimension is never set, even though I can see the 'set' command being executed (ignore the timestamps in the console, I forgot to screenshot before navigating away from the site and had to go back and reload the page):
The live site does not use the default tracker, hence the ga.getAll() call to access the tracker information.
From what I can see, everything should work fine.
I understand that from reviewing this question
Google Analytics Custom Dimension Not Being Set
that the 'set' needs to come before the 'send'.
I'm not sure how to accomplish this though since the plugin does not send the pageview to GA, from what I understand, that's Google Site Kit. I have contemplated adding a 2nd pageview send when this plugins code is loaded (it is only executed immediately after a registration and never again), but that would skew the page hits.
This site has had a myriad of "admins" over the years, so I wouldn't be surprised if there was something buried in one of the plugins causing a conflict somewhere. At one point I thought it was a timing issue, so I had the function load every 50 milliseconds checking for 'ga' to be defined, then execute the 'set' command (with a limit to 35 iterations), but the issue was the same (could set the command execute in the console, but the dimension did not reflect the value).
Any advice I can get to debug and get to the root cause would be of great assistance to me. Please ask any questions you need and I will respond as quickly as possible.
It seems a bit complex as a situation so understanding how it works and why there is gtag and ga at the same time is not easy to understand.
In any case, assuming that everything is working, what you can do is not to send a second pageview but send a dedicated event (by setting non-interaction to true) in this way you do not alter any information in Google Analytics and you can pass to the platform the data you are interested in (dimension1).
I have an angular.js webapp and I´m using Google Analytics. On 16/11 I migrated my angular webapp from the old universal google-analytics.js script to the new gtag.js. Next day, I stopped to getting analytics information. See the screenshot.
Some considerations:
I just migrated the js in the webapp.
I didn´t change any configuration in Google Analytics.
With the purpose to filter spam or ghost visits in GA, since a long time ago I had a filter that I "expected" to allow analytics only from my site, like:
I have another view without any filter that I have noticed that seems to work. So for some reason the root cause could be the filter.
Also, I have noticed the real-time reports are not working in the filtered view, however, they are working in the not filtered view.
For testing purposes, I have just deleted the filter and the real-time reports are working.
As before the migration, I was gathering analytics, I think there are maybe different problems:
- It looks like the filter is (and was before the migration) preventing the real-time reports to work.
- Apart from the real-time reports, the analytics were working before the migration with the filter, so is there anything that needs to be changed, updated in analytics in order the gtag.js works. Or maybe gtag.js is working in a different way that makes analytics not work with that filter?
- Should I delete the filter in any case? At the moment, I have deleted it and I will observe what happens with the analytics next days. However, if I delete the filter the spam analytics will come back. Maybe there is another filter that has to be applied.
UPDATE:
I attach the Gtag.js script in the website:
<script async src="https://www.googletagmanager.com/gtag/js?id=UA-property-1"></script>
<script>
var gaEnv;
switch (window.location.hostname) {
case 'www.domain.com':
gaEnv = 'UA-property-1'; // production
break;
case 'www.test.domain.com':
gaEnv = 'UA-property-3'; // test
break;
default:
gaEnv = 'UA-property-2'; // development
}
window.dataLayer = window.dataLayer || [];
function gtag(){dataLayer.push(arguments);}
gtag('js', new Date());
// Config for analytics
gtag('config', gaEnv, { 'send_page_view': false });
// Config for Adwords
gtag('config', 'AW-property');
</script>
As I use Angularjs I hace developed a service to track page views, like:
service.trackPageView = function (url) {
gtag('config', trackingId, {'page_location': url});
/* Old code for google-analytics.js. deprecated with gtag.js
* ga('set', 'page', url);
* ga('send', 'pageview', url); */
};
UPDATE 2: I have installed Google Tag Assistant. It looks like it´s gathering the data and tracking the pageviews. The only strange thing that I see is the alert: This hit is missing the hostname in the URI.
UPDATE 3: As I suspected, when I delete the "include only" my hostname filter in the analytics view, the data is gathered again as you can see in the pic.
So, it´s pretty clear that gtag.js is sendind data from the app to Analytics to the right property.
Now, the only point is that I had that filter that I have deleted to filter the ghost analytics spam. So, I assume it will be back soon. Again to the starting point.
My concern is if it´s maybe related to the info that I send to analytics or maybe the filter was wrong. So, I think I will need help to setup the filter working properly with this gtag.js library.
I'm changing google analytics for google tag manager on an existing website. This website also uses google e-commerce, so I have a few custom ga() calls related to the e-commerce being done on some pages.
The problem is that because the google analytics script loads asynchronously, ga() is not defined anymore when I'm trying to send some e-commerce related data.
I've found a workaround somewhere:
window['GoogleAnalyticsObject'] = 'ga';
window['ga'] = window['ga'] || function() {
(window['ga'].q = window['ga'].q || []).push(arguments)
};
But, although I've not the "ga is not defined" problem anymore, it still doesn't work.
I don't see anything on the google dashboard. I also don't see anything on the debugging messages (in the developer console).
What seems to be happening is that the GA script loaded with GMT is not using these variables I've set but I'm not sure how to fix it or if it is even possible to keep using my ga() calls with GMT.
I know that I can do it with dataLayer but I'm trying to avoid to rewrite a bunch of working code just for this.
I have seen an implementation that does it like this:
window.ga=window.ga||function(){(ga.q=ga.q||[]).push(arguments)};ga.l=+new Date;
ga('create', UA-XXXXXXXXXX, 'auto');
ga('require', 'ecommerce');
maybe that works out for you as well.
if you use enhanced e-commerce then the code below the "ga('create..." hast to change from:
ga('require', 'ecommerce');
to:
ga('require', 'ec');
The order is important here, events can be send after those functions.
Does anyone know if it's possible to capture the variables from an Adobe Analytics implementation and pass them to GTM so that they can be used as custom dimensions in Google Analytics?
I was wondering if there was some javascript that i could implement in GTM that would extract the neccessary props i want from the adobe data layer, but im not a developer so im not even sure if this is possible.
Thank you!
This looks to me like exactly the guide you are looking for:
http://blogs.perficient.com/adobe/2017/04/12/custom-adobe-analytics-tracking-using-google-tag-manager/
I don't have any personal experience with Adobe Analytics so I cannot help you further than that. However I can tell you what you are trying to achieve is most definitely possible.
This is definitely possible and not hard to pull off. There is even a google analytics tool than can be used for adobe dtm.
Just doing it manually through code, make sure that GA is already present on the page, and fire this code in a third party script after you AA variables are set.
ga('set', 'dimension1', value1);
ga('send', 'pageview');
You can set multiple dimensions at once:
ga('ehiglobal.set', {
'dimension2': value2,
'dimension3': value3,
'dimension4': value4
});
You can also pass specific page names on the hit:
ga('send', 'pageview', location.pathname);
You can also send an event hit if you already have page views set up:
ga('send', 'event', 'category', 'action', {
'dimension5': value5
});
**Note: You need to send the data through a page view or a hit. Just setting the data wont do anything, so make sure you actually have one of the send events
I am trying to confirm a 'pageview' is being processed properly.
( using google real time dashboard ).
The issue is simple, If I use this call:
// page uri is: www.example.com/signup
ga( 'send', 'pageview' );
I see a matching entry at google's dashboard.
Attempting to override the title / page parameters ( according to the docs ) like so:
ga( 'send', 'pageview', {
'page': '/admin/logout',
'title': "test"
} );
Simply produces nothing over at google's side.
Any idea what is going on?
EDIT
It appears that google analytics service is filtering pages that contain
the word "admin".
Removing that from the 'page' helped in my case.
I don't know what's going on because your syntax is definitely correct.
FWIW, while the real time dashboard is a great way to see your hits come in, it should not be considered proof or evidence that something is or isn't working. Everything you send to Google Analytics goes through processing after it comes in, and (for a variety of reasons) a hit may be dropped from reports after showing up successfully in the real time view.
There's also always the possibility that there's a bug in the real time dashboard, and a particular hit may not show up even though it will ultimately make it into your Google Analytics reports.
A much more reliable way to see if your code is working is to take a look at the data that is actually being sent from your page. You can do this via the network inspector (in Chrome) or by using the debug version of analytics.js, which logs status and error message to the console.