I'm using the enhanced ecommerce tracking from Google Analytics to send data like this in JS to GA:
ga("ec:addImpression", {
brand: null,
dimension2: "shop123",
id: 1,
list: "Search",
name: "Product 123",
position: 1
});
ga("send", "pageview");
Then, I use the Reporting API to generate some charts. Here, I want to filter by my custom dimension dimension2. The request looks like this:
{
"reportRequests":[
{
"dateRanges":[
{
"startDate":"2016-10-17",
"endDate":"2016-11-16"
}
],
"viewId":"132093148",
"metrics":[
{
"expression":"ga:productListViews"
}
],
"dimensions":[
{
"name":"ga:date"
},
{
"name":"ga:dimension2"
}
],
"dimensionFilterClauses":[
{
"filters":[
{
"dimension_name":"ga:dimension2",
"operator":"EXACT",
"expressions":[
"shop123"
]
}
]
}
]
}
]
}
However, this returns no results:
{
"reports":[
{
"columnHeader":{
"dimensions":[
"ga:date",
"ga:dimension2"
],
"metricHeader":{
"metricHeaderEntries":[
{
"name":"ga:productListViews",
"type":"INTEGER"
}
]
}
},
"data":{
"totals":[
{
"values":[
"0"
]
}
]
}
}
]
}
But when I remove the dimensionFilterClauses I get all the results, of course not filtered by dimension2.
Did I anything wrong when filtering for that dimension?
Change your string dimension_name for dimensionName and try.
As you can see in the examples: https://developers.google.com/analytics/devguides/reporting/core/v4/samples
"dimensionFilter":
{
"dimensionName":"ga:browser",
"operator":"EXACT",
"expressions":["Safari"]
}
Related
Some API geocode queries return double results when this is not warranted by the real data.
It will return 2 results with slightly different latitude and longitude and different LocationId's.
This makes it difficult if not impossible to decern which one is the correct result.
Example:
https://geocoder.ls.hereapi.com/6.2/geocode.json?apiKey=8888&city=Zutphen&country=NL
Returns:
{
"Response":{..
},
"View":[
{
"Result":[
{
"Relevance":1.0,
"MatchLevel":"city",
"MatchQuality":{
"City":1.0
},
"Location":{
**"LocationId":"here:cm:namedplace:23055957",**
"LocationType":"point",
**"DisplayPosition":{
"Latitude":52.1402,
"Longitude":6.19152**
},
...
},
"Address":{
"Label":"Zutphen, Gelderland, Nederland",
"Country":"NLD",
"State":"Gelderland",
"County":"Zutphen",
"City":"Zutphen",
"PostalCode":"7201",
"AdditionalData":[
{
"value":"Nederland",
"key":"CountryName"
},
{
"value":"Gelderland",
"key":"StateName"
},
{
"value":"Zutphen",
"key":"CountyName"
}
]
}
}
},
{
"Relevance":1.0,
"MatchLevel":"city",
"MatchQuality":{
"City":1.0
},
"Location":{
**"LocationId":"here:cm:namedplace:20201443",**
"LocationType":"point",
**"DisplayPosition":{
"Latitude":52.13764,
"Longitude":6.20777**
},
...
],
"ViewId":0
}
]
}
}
I am using Drupal 8 JSON:API to expose data to my Gatsby site. I have built a GraphQL query to expose a list of "officers" which contains a field with a relationship to a set of "service periods". The data returned by the API is correct, but I would like to filter for only one specific child record (service period) and can not figure out how to do that. My query is:
officerList: allGroupContentLodgeGroupNodeOfficer(filter: {relationships: {entity_id: {relationships: {field_position: {elemMatch: {relationships: {field_service_period: {drupal_internal__tid: {eq: 203}}}}}}}}}) {
edges {
node {
r: relationships {
entity_id {
r: relationships {
field_position {
r: relationships {
field_position {
name
}
field_service_period {
name
drupal_internal__tid
}
}
}
}
title
}
}
}
}
}
}
The resulting JSON set is:
"data": {
"officerList": {
"edges": [
{
"node": {
"r": {
"entity_id": {
"r": {
"field_position": [
{
"r": {
"field_position": {
"name": "Governor"
},
"field_service_period": {
"name": "2018 - 2019",
"drupal_internal__tid": 203
}
}
},
{
"r": {
"field_position": {
"name": "Junior Past Governor"
},
"field_service_period": {
"name": "2019 - 2020",
"drupal_internal__tid": 204
}
}
}
]
},
"title": "Tom Jones"
}
}
}
}
]
}
}
}
I understand the resulting set is correct because the child is within the root. However, I can not see how to filter the full query to include only certain child records. Is this even possible? I have seen some implementations of GraphQL that seem to allow filters to be placed on children, but I don't think this is possible in Gatsby.
I have searched everywhere for possible solutions and have been banging my head against the wall for a few days. Any insight is GREATLY appreciated!
TIA!
I have create this script:
function myCalendar(){
var now=new Date();
var startpoint=new Date(now.getTime()-60*60*24*1000*1);
var endpoint=new Date(now.getTime()+60*60*24*1000*10);
var events=CalendarApp.getCalendarById("my.email#google.com").getEvents(startpoint, endpoint);
var ss=SpreadsheetApp.getActiveSpreadsheet().getSheetByName("MyScedule");
ss.clear();
for (var i=0;i<events.length;i++) {
ss.getRange(i+1,1).setValue(events[i].getTitle());
ss.getRange(i+1,2).setValue(events[i].getDescription());
ss.getRange(i+1,3).setValue(events[i].getStartTime());
ss.getRange(i+1,4).setValue(events[i].getEndTime());
// HERE I WILL ADD THE FREE/BUSY-STATUS <<<<<--------------
}
}
This script runs perfect. but how I can add the free/busy-status?
Thanks
To get the free/busy status you have to do a query to the Calendar API (not calendarApp) and then you will get all the events with the param BUSY. So you can default the parameter to Free unless the query returns Busy.
This is how the parameters can look like:
"resource": {
"timeMax": "2020-03-15T03:30:00+05:30",
"timeMin": "2020-01-01T03:30:00+05:30",
"calendarExpansionMax": 3,
"items": [
{
"id": "CALENDAR ID"
}
]
}
And this is how the response will look like:
{
"kind": "calendar#freeBusy",
"timeMin": "2019-12-31T22:00:00.000Z",
"timeMax": "2020-03-14T22:00:00.000Z",
"calendars": {
"CALENDAR ID": {
"busy": [
{
"start": "2020-01-02T23:00:00Z",
"end": "2020-01-03T23:00:00Z"
}
]
}
}
}
You can try it with your calendar here: Freebusy: query
I can't figure out how to use the gatsby-plugin-feed to add some custom content from my frontmatter to the rss feed. Here is my config:
{
resolve: `gatsby-plugin-feed`,
options: {
query: `
{
site {
siteMetadata {
title
description
siteUrl
site_url: siteUrl
}
}
}
`,
feeds: [
{
serialize: ({ query: { site, allMarkdownRemark } }) => {
return allMarkdownRemark.edges.map(edge => ({
...edge.node.frontmatter,
description: edge.node.excerpt,
url: site.siteMetadata.siteUrl + edge.node.fields.slug,
guid: site.siteMetadata.siteUrl + edge.node.fields.slug,
}));
},
query: `
{
allMarkdownRemark(
limit: 1000,
sort: { order: DESC, fields: [fields___prefix] },
filter: { fields: { source: {eq: "posts"}, slug: { ne: null } } }
) {
edges {
node {
excerpt
html
fields {
slug
prefix
}
frontmatter {
title
subtitle
tags
categories
youtube
}
}
}
}
}
`,
output: '/rss.xml',
},
],
},
},
I thought that using the spread operator on the edge.node.frontmatter object would add all of the fields but that resulting item is missing a ton of the frontmatter fields.
I am sure I am missing something, or I don't understand something about rss feeds. Can anyone point me in the correct direction? Thank you.
I have a basic index with logs
Some logs are visit of user1 to user2
I managed to count the total of visits a user has received, but I don't know how count the total of distinct users a user has received
This is giving me all the logs for a user
{
"post_filter":{
"bool":{
"must":[
{
"term":{
"message":"visit"
}
},
{
"term":{
"ctxt_user2":"733264"
}
}
]
}
},
"query":{
"match_all":{}
}
}
Actually, I'm using FoSElasticaBundle for Symfony2
$filter->addMust((new Term())->setTerm('message', 'visit'));
$filter->addMust((new Term())->setTerm('ctxt_user2', $this->search->getVisit()));
I read some pages in the ES doc with aggregator, but I never managed to get what I want
Convert to SQL, I just need
SELECT COUNT(DISCTING ctxt_user1)
FROM logs
WHERE ctxt_user2 = 733264
EDIT:
Cardinality seams to be what I need.
Now just need to find how use it with FosElasticaBundle
"aggs": {
"yourdistinctcount": {
"cardinality": {
"field": "ctxt_user1"
}
}
}
Try this query ( not tested...):
{
"query" : {
"bool":{
"must":[
{
"term":{
"message":"visit"
}
},
{
"term":{
"ctxt_user2":"733264"
}
}
]
}
},
"aggs": {
"yourdistinctcount": {
"terms": {
"field": "ctxt_user1"
}
}
}
}
The post_filter query cannot be used in your case. As it write on Elastic.co website: The post_filter is applied to the search hits at the very end of a search request, after aggregations have already been calculated.`
HtH,