Combine 2 url filter in one cell google spreadsheet, "ga:pagePath==/url1,url2" - api

enter image description here]1
I have a website with 5 pages on it. Every filter on google sheets using google analytics API is written like:
ga:pagePath==/home,ga:pagePath==/,ga:pagePath==/mapa,ga:pagePath==/producto,ga:pagePath==/horario,ga:pagePath==/pago.
I want to mix "/home" and "/", I think something like ga:pagePath==//|/home?
please help. there is a picture explaining I want to save both values in one cell.
It's like 780+525 in one cell
Thanks guys I'm new to the business

You have to use tilde symbol for regex, like this:
ga:pagePath=~^/$|/home

Related

How to extract specific lines from a text document?

I am no expert in coding or anything but I figured it out this website would be the best to achieve what I want. So, I got my personal data from Spotify, and they give you how much you played a song and all of the play history and I want to calculate how much I listened in total, the problem is I don't know how can I extract the specific lines from the text document with only the time and then calculate it.
The text is something like this:
{
"endTime" : "2020-11-21 22:23",
"artistName" : "Kanye West",
"trackName" : "Devil In A New Dress",
"msPlayed" : 351946
},
and there are a lot of songs, I just want to extract the "msPlayed" thing so I can calculate it, any help?
Go here: https://regex101.com/r/RLDYUj/1
Put your text into the "Test String" part
Copy in your clipboard the numbers list in the "Substitution" part
Go here: https://miniwebtool.com/sum-calculator/
Paste the numbers list and compute the sum

Google Sheets IMPORTXML: Xpath not working (document node does provide data)

Using Google Sheets, I am trying to retrieve text passages from the Perseus Scaife Library, which has a working API.
When I query for the document node (=importxml("https://scaife-cts.perseus.org/api/cts?request=GetPassage&urn=urn:cts:greekLit:tlg0527.tlg001.opp-grc2:1.1","/")) I get all the data, including the URNs etc. However, any other xpath_query gives an error.
I know that Google Sheets can access the data, but I would like to be able to select only one node (//p).
You want to retrieve the text in passage. If my understanding is correct, how about this answer?
=importxml(A1, "//*[local-name()='passage']")
Result :
Note :
https://scaife-cts.perseus.org/api/cts?request=GetPassage&urn=urn:cts:greekLit:tlg0527.tlg001.opp-grc2:1.1 is converted by URL encode and put to "A1".
Converted URL is https://scaife-cts.perseus.org/api/cts?request=GetPassage&urn=urn%3acts%3agreekLit%3atlg0527%2etlg001%2eopp%2dgrc2%3a1%2e1.
Reference :
local-name
If this was not what you want, I'm sorry.

The first result in Google is not my homepage

When you type hackisition on Google, it returns the following url as first result:
https://www.hackisition.com/en/
// instead of
https://www.hackisition.com/
I'd like to replace that link by the real homepage. How can I do that? Is there a way to specifically ask Google to show this homepage?
I am getting "https://www.hackisition.com/" as first result for "hackisition". I'm not sure why you're getting such result. Try to clear cookies and turn off VPN/Proxy if you're using one.
We are getting result as you said , so I suggest to clear cache
Maybe that is because of User location.
That mean countries preferred English on search would be able to see /en
and other countries that not prefer English will see the non /en result.
Search your website on
Google.ae
Google.DK
you'll see https://www.hackisition.com in result not https://www.hackisition.com/en.
But if you search in Google.com, Google.eu you'll see the result https://www.hackisition.com/en
Hope this would be the solution of your problem.

Use custom function to populate gSpreadsheet cell based on a XML/JSON response

Ok, this one has become a little tricky for me and I really need some assistance to work through it.
Problem
I have a GSpreadsheet which has a list of data, in this case Twitter usernames. Using the API of a service provider (in this case the Klout API), I would like to retrieve information about that user to populate a cell within a spreadsheet.
Based on what I can work out so far, I would need to write a custom function to do this but I have no idea where to start, how I might construct it, or if there are any examples of doing this.
Scenario
The Klout API can return either an XML or JSON response (see http://developer.klout.com/docs/read/api/API), based on the string passed. For example, the URL:
http://api.klout.com/1/users/show.xml?key=SECRET&users=thewinchesterau
would return the following XML response:
<users>
<user>
<twitter_id>17439480</twitter_id>
<twitter_screen_name>thewinchesterau</twitter_screen_name>
<score>
<kscore>56.63</kscore>
<slope>0</slope>
<description>creates content that is spread throughout their network and drives discussions.</description>
<kclass_id>10</kclass_id>
<kclass>Socializer</kclass>
<kclass_description>You are the hub of social scenes and people count on you to find out what's happening. You are quick to connect people and readily share your social savvy. Your followers appreciate your network and generosity.</kclass_description>
<kscore_description>thewinchesterau has a low level ofinfluence.</kscore_description>
<network_score>58.06</network_score>
<amplification_score>29.16</amplification_score>
<true_reach>90</true_reach>
<delta_1day>0.3</delta_1day>
<delta_5day>0.5</delta_5day>
</score>
</user>
</users>
Based on this response, I would like to be able to populate different cells with the values returned within the XML (or JSON if easier) packet.
So, for example, I would have a spreadsheet like the following which would have custom functions to go out and retrieve the value of the relevant XML element response to populate the cell:
Cell A B C D E
1 Username kscore Network score Amplification score True reach
2 thewinchester =kscore(A2) =nscore(A2) =ascore(A2) =tscore(A2)
Questions
Are there any gSpreadsheet examples you know of that use an API to pull data in from an external source?
How would one write a custom function to fetch the result from the API and populate a cell with a result of a specific element?
Any information, examples or helpers you have are greatly appreciated.
You want the importXML function, documented here. The formula you want will look something like this:
=importXML("http://api.klout.com/1/users/show.xml?key=SECRET&users=" + A1, "//users/user/score/kscore")
You could write a custom script with Google AppScript, but there's a simple solution to this similar to what Nick Johnson posted. I've tested this against the score function, but it could be easily adapted to the show endpoint with different XPath.
=importXML("http://api.klout.com/1/klout.xml?users="&A1&"&key=YOUR_API_KEY", "//users/user/kscore")
This presumes your Twitter IDs are in the A column.
Note, Google Docs limits the number of such importXML functions to 50 per spreadsheet. You could concatenate groups of 5 userids for each importXML call, effectively putting your limit to 250 a sheet.
This could also be adapted to a similar call in Excel that doesn't have that limit. Keep in mind the Klout ToS, though, using proper attribution and rate limits.

google analytics API, how to extract pageviews for a specific page?

Google Analytics API: how to extract pageviews for a specific page?
I tried using something like
ga:pagePath=~page.php%3fid%3d44 (page.php?id=44)
but it doesn't seem to work... I get "no results found" where I have 20 pageviews for sure
UPDATE
I think I found the solution
ga:pagePath==/website/page.php?id=44
for some reason I had to include the complete path and ==
To use a partial path to match for a page in filters you should use
ga:pagePath=#page.php?id=44
=# tells ga to match a substring.
What you were originally using was incorrect for this.
I think your problem is that you put the hex version of the ? and = characters into your query, which doesn't match how Analytics stores the page paths. If you change these to the normal characters it should work:
ga:pagePath=~page.php?id=44
Your other solution should work as well but is a bit more inflexible in case you wanted to tweak the query to return other pages.