How to setup GA with multiple accounts and reports - google-analytics

Hey Guys, i need some help about with a setup of GA in one site.
This site have information from 2 account, 1 for consolidated and another for country. Yesterday I tried to add another ID (third ID) for TI purposes but when I a looked the stats in GA have been lost.
This is the code, it's correct?
var pageTrackerCons = _gat._getTracker("UA-5352676-2");
pageTrackerCons._setDomainName("none");
pageTrackerCons._setAllowLinker(true);
pageTrackerCons._setCustomVar(1,"Login","No",2);
pageTrackerCons._trackPageview();
var pageTrackerPais = _gat._getTracker("UA-5358924-2");
pageTrackerPais._setDomainName("none");
pageTrackerPais._setAllowLinker(true);
pageTrackerPais._setCustomVar(1,"Login","No",2);
pageTrackerPais._trackPageview();
var pageTrackerServ1 = _gat._getTracker("UA-22944815-2");
pageTrackerServ1._setDomainName("none");
pageTrackerServ1._setAllowLinker(true);
pageTrackerServ1._trackPageview();
UA-22944815-2 es de the new ID with the problems, stats for anothers accounts are fine.
Can we use 3 diferents ID in one site? How?
Thanks in advance

Yes, it's totally possible to use 3 trackers on one page and send data to 3 accounts.
Your code looks correct, maybe it's just a delay in reporting. It may happen that data only shows up after a day or two.
You should first confirm that you have 3 GIF requests to the google-analytics.com servers, each which that utmac parameter matching the accounts that you are expecting.
If you have a GIF request with utmac=UA-22944815-2 , then it means data is collected for your new account. Make sure you look at the right profile, and that the profile has no filters.

Related

Google Analytics Data API - way to small values or missing data

Has anyone tried the new Google Analytics Data Api (still in beta) for a GA4-Property?
We did this, the way it is recommended in the docs here: https://developers.google.com/analytics/devguides/reporting/data/v1/quickstart-client-libraries
Connection and authorization is working fine, but the values that are responded are way to small. For example it reported activeUsers for last 7 days as 50...but Analyitcs GUI has about 20.000...same as our old UA-Property that runs parallel. And the old reporting Api has the correct numbers...
We did it exactly like the reference example...
client = BetaAnalyticsDataClient()
request = RunReportRequest(
property="properties/{0}".format(self.property),
dimensions=[Dimension(name="defaultChannelGrouping")],
metrics=[Metric(name="activeUsers")],
date_ranges=[DateRange(start_date="7daysAgo", end_date="today")],
)
response = client.run_report(request)
print("Report result:")
for row in response.rows:
print(row.dimension_values[0].value, row.metric_values[0].value)
This gives me:
Organic Search 34
Paid Search 19
Direct 6
Referral 3
Email 1
So "organic" for example should be around 20.000!
Funny thing is even the Query Explorer App (https://ga-dev-tools.web.app/query-explorer/) is showing these low numbers for the GA4-Property...
Any ideas what could be wrong? Thanks!

Google Analytics: segment discrepancy between API and web reporting

I've had an analytics reporting API running for a while now and unfiltered view results from the API match the web reporting. The issue I'm seeing is when adding a segment to the API report request. The web reporting is frequently returning different values than the API for a handful of the segment/view_id combinations. I'm looking for a recommended settings to review here to understand what is causing the discrepancy, as I'm not sure if this is an program code/API issue, web reporting issue or a configuration for segment/view_id issue.
Notes:
When incorrect, it appears that the web reporting numbers for sessions is averaging 10% higher than what the API returns
A single segment is applied to many view_ids we manage and a high percentage (~80%) are showing the discrepancy, the remainder match.
the modified and created dates for this segment are 5 months old per the web interface, meaning there is not a configuration change within the segment causing the discrepancy
we've compared 2018 YTD to eliminate a time lag data update as an issue.
segments appear to be link to our master account level and applied to the accounts we manage.
currently using v4 of the analytics API for .Net (C#)
Current Questions:
Could this be a setting in how a particular segment was created?
Why would some segment/view_ids match and others not?
Is there a account, property or view_id permission/configuration setting to review as it relates to applying segments?
Any help or insights on what to review here would be helpful.
Forgot the code snippet:
var segmentDimension = new Dimension { Name = "ga:segment" };
var DefaultReportRequest = new ReportRequest
{
DateRanges = new List<DateRange> { dateRange },
Dimensions = new List<Dimension> { date, SourceMedium, Campaign, AdContent, Keyword },
Metrics = new List<Metric> { sessions, Users, NewUsers, Bounces, pageViews, SessionDuration, Goal01Completion, Goal02Completion, Goal03Completion, Goal04Completion },
ViewId = v_id,
PageSize = 10000
};
if (!(segmentId == ""))
{
DefaultReportRequest.Dimensions.Add(segmentDimension);
Google.Apis.AnalyticsReporting.v4.Data.Segment segment = new Google.Apis.AnalyticsReporting.v4.Data.Segment() { SegmentId = segmentId };
DefaultReportRequest.Segments = new List<Google.Apis.AnalyticsReporting.v4.Data.Segment> { segment };
};
var getReportsRequest5 = new GetReportsRequest
{
ReportRequests = new List<ReportRequest> { DefaultReportRequest }
};
var batchRequest5 = reportingService.Reports.BatchGet(getReportsRequest5);
var response5 = batchRequest5.Execute();
Thanks in advance for your help,
Mike
Update 2:
After reviewing this further the API call is always pulling a single day of data "Yesterday". The web reporting when pulling that single specific day of data matches. If the web reporting pulls a time range of data around those specific dates (ex: +/- 3 days) the numbers no longer match. It seems like sampling could be in play here, but the web reports we are running indicate 100% of sessions in both pulls. I think the question is how to determine which is more accurate a single day or a time range of data. Has anyone investigate this, I've reproduced it on several of our view_ids.
Thanks,
Mike
Update 3 (rseolution):
Turns out the issue was with how the segment was created and being applied to web reporting. The segment was focused at the User level, meaning aggregated values would change based on the time frame selected. The desired state was having the filters apply to a single day, making session focus a better then user as it contained the segment to the session.
Thanks all,
Mike
Without knowing too much about the details of the segments and views, the first thing I'd like to confirm with you is that you're aware of sampling in GA.
Unless they're all 360 accounts, you'll be subjected to sampling depending on the sessions you're returning for 2018 YTD. Note, sampling is based on sessions on the property level, not view level.
Another thing you can do in your code is to check if the sampling of the % of data matches with the web version VIA the response from the API. On the web version, the sampling info is here:https://i.stack.imgur.com/hcPGD.png

Google analytics user explorer get user report

How do I get user report from user explorer, using GA API. Didn't manage to find any information about it here https://developers.google.com/analytics/. For instance in user explorer (audiences section) you can see a list of records having ids like 11111111111.2222222222 and I want to get information about user activity on the website for record with id 11111111111.2222222222 using GA API
While the latest GA release notes says the client ids have been "surfaced" (i.e. made visible) it is (at least currently) not available as a dimension via the API. So if you want to use it you'd have to add the client id as a custom dimension to your reports yourself. Off the top of my hat this should look something like this:
ga(function() {
var trackers = ga.getAll();
trackers.forEach(function(tracker) {
tracker.set('dimension1',tracker.get('clientId'));
});
});
Put before the pageview this would write the client id to your custom dimension with the index 1 (which you need to create in advance via the interface in properties->custom definitions). Should also work with multiple trackers on the same page.
This will of course not help you with data that's already been collected.

Universal analytics goal tracking

I have set up goal to URL destination: '/pageview.html'.
If I execute below URL on my universal analytic page views will increase by 1 (which is correct). Also my goal will increase by 1 (which is also correct).
Link 1 example
http://www.google-analytics.com/collect?v=1&tid=UA-XXXXXX-4&cid=987987987&t=pageview&sr=-&sd=-&ul=-&je=0&fl=-&dt=%2Fphonecallleads.html&dh=www.wednesday.co.uk&dr=http%3A%2F%2Fwww.wednesday.co.uk%2Fbla%3Fhehe%3Dvisitor&dp=/phonecallleads.html&z=321321321
How ever if I execute the same link again but with different number in 'z' parameter to prevent caching on my analytic page views will increase by 1 (which is correct) but my goal will not increase... Why is my goal not increasing ?
Link example 2 witch different 'z' parameter
http://www.google-analytics.com/collect?v=1&tid=UA-XXXXXX-4&cid=987987987&t=pageview&sr=-&sd=-&ul=-&je=0&fl=-&dt=%2Fphonecallleads.html&dh=www.wednesday.co.uk&dr=http%3A%2F%2Fwww.wednesday.co.uk%2Fbla%3Fhehe%3Dvisitor&dp=/phonecallleads.html&z=654654654
Thank you Eike Pierstorff.
The issue was that UA counts goals only once per session.
To resolve that issue I have added an extra parameter to the URL - Session control which starts new session once request is submitted.
&sc=start

Linkedin - Get companies updates queries

I'm trying to create an app to read company updates, but I have a few queries. Please help...
I'm using LinkedIn api via Oauth authentication in R
Is there anyway to fetch more updates than the restriction (only allow fetch up to 250 updates or updates in the last 20 days whichever comes first) ?
Example code
https://api.linkedin.com/v1/companies/270126/updates?event-type=status-update&count=100&start=0 &oauth2_access_token={access_token}
Once I got the updateKey, I'm trying to fetch the comments and likes but it's returning NO return
Example code
https://api.linkedin.com/v1/companies/270126/updates/key=UPDATE-c270126-5951438751136768000/update-comments?event-type=status-update&oauth2_access_token={access_token}
https://api.linkedin.com/v1/companies/270126/updates/key=UPDATE-c270126-5951438751136768000/likes?event-type=status-update&oauth2_access_token={access_token}
From the company status-update, it's returning FALSE for is-commentable and is-likable? Is that why there are no result from Query 2. If so, is there anyway to change that setting?
'is-commentable' false '/is-commentable'
'is-likable' false '/is-likable'
Any help would be greatly appreciated!!!!
Linkedin developer - Reading Company Shares link
https://developer.linkedin.com/reading-company-shares
Try using the Share and Social Stream end point instead of the Companies end point like this:
https://api.linkedin.com/v1/people/~/network/updates/key=UPDATE-c270126-5951438751136768000/update-comments?oauth2_access_token={access_token}
The documentation is here:
https://developer.linkedin.com/documents/commenting-reading-comments-and-likes-network-updates
Also you can test different Linkedin API calls here:
https://apigee.com/console/linkedin

Resources