I'm working with the Google Analytics API, and am pulling a lot of data from it successfully. The accounts feed (https://www.google.com/analytics/feeds/accounts/default) returns a list of web properties connected to the account you're authorized for, in the following format (most actual values replaced, not sure how sensitive any of it is):
<entry gd:etag="W/"<charsblahblahblah>."" gd:kind="analytics#account">
<id>http://www.google.com/analytics/feeds/accounts/ga:########</id>
<updated>2011-08-04T12:01:33.467-07:00</updated>
<title>www.afifthofnothing.com</title>
<link rel="alternate" type="text/html" href="http://www.google.com/analytics"/>
<dxp:property name="ga:accountId" value="#####"/>
<dxp:property name="ga:accountName" value="My Sites"/>
<dxp:property name="ga:profileId" value="######"/>
<dxp:property name="ga:webPropertyId" value="UA-#####-#"/>
<dxp:property name="ga:currency" value="USD"/>
<dxp:property name="ga:timezone" value="America/Los_Angeles"/>
<dxp:tableId>ga:#######</dxp:tableId>
</entry>
I've previously been using the <title> element as the base URL for the property, which usually works because that's the default title that Google Analytics assigns to the property. But if a user edits this (I'm querying my end-users' accounts, so I don't have control there) to something like "A Fifth Of Nothing", then the Analytics API will dutifully return that as the title, leaving me with no way to find the base URL.
I've scoured the Analytics API documentation and googled around, searched SO, but don't see any way to get the base URL of a web property from Google Analytics. I've tried querying the id field via the OAuth Playground for more info, and it just gives me more errors, saying the last part has to be /default.
Is there a way to get the base URL for a user's properties from the data API? It seems like this would be something pretty basic. If not, I'll have to resort to trying the title, and if it's not URL-like just have the user enter it themselves, which is not very user-friendly, but is the only thing I can come up with at this point.
The strategy to use is to do a query against the ga:hostname dimension for ga:visits and sort descending. You typically can use this to reveal the host/base url.
I don't think there is such a property for the "base url" because technically you can put the google tracking code on multiple websites. And in this instance you would have multiple base url.
View Full Page URL In Reports
By default, the data in your reports includes only the Request URI and not the domain name:
URL of page: http://www.example.com/foldername/page.html
Request URI: /foldername/page.html
Domain name: www.example.com
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
Note that creating URL rewrite filters like the one described above can affect Analytics' ability to match your goals properly.
If you're using Analytics filters to rewrite your URLs, you need to make sure that your goal settings reflect these changes. Like all filters, URL-rewrite filters are applied to the raw data coming into your account, before goals are processed. As a result, your goal and funnel URLs should reflect the final, rewritten format of the URL. For example:
If your site's URL:
/directory/download/file.html
is rewritten by a filter to look like:
/download/file
then your goal should match
/download/file and not /directory/download/file.html
Related
I need to incorporate my own parameters as part of url. (e.g. #student=DD&start=Date1&end=Date2). However, I am cerncerning about if I add my part to the url, will it mess up my google analytics tracking? Basically, now my url is something like -- MywebsiteUrl?userID=AAA#student=DD&start=Date1&end=Date2&utm_source=CC....
What url Google analytics will track? is my website url -- MywebsiteUrl, or ``MywebsiteUrl?userID=AAA#student=DD&start=Date1&end=Date2`?
Thanks in advance!
Google Analytics will treat query parameters as part of the URL. However it will not treat #student=DD&start=Date1&end=Date2 as having query paramaters. As far as (native) Javascript and the GA tracking code is concerned the URL ends after the fragment identifier (#).
So your complete example
MywebsiteUrl?userID=AAA#student=DD&start=Date1&end=Date2&utm_source=CC
you will get MywebsiteUrl?userID=AAA. If the userID parameter contains personally identifiable information you need to remove it to conform to Google's terms of service. You can use a filter or the exclude parameters-box in the view settings.
We have an instance of cross-domain tracking within Google Analytics with a single sign-on between sites. The sites are on GTM. The single sign-on generates a Google Analytics id such as (?_ga=1.18339449.1954186898.1485354375) which are appended to the end of page URL's.
Our preference is that the id's do not appear within page level reporting as GA treats each page as unique which in turn increases the chances of sampling. We've been unable to use the "Exclude URL Query Parameters" feature found within the view settings to remove the parameters from page level reporting.
I could not find blog or stack overflow posts specifically stating how to remove the id parameters from within Google Analytics reporting.
Is there a suggested alternative to prevent the id parameters from being appended to the sites page URL's?
If you aren't able to use the Exclude URL Query Parameters option to strip the parameter from the URL...that stinks. You might want to let Google know the feature isn't working as expected.
Another option is to use an Advanced filter with regex to strip the parameter from the Page. You can do this with the following settings:
Field A: Request URI
Pattern: ^(.+)\?_ga
Output To -> Constructor
Request URI
Pattern: $A1
This is a quick and dirty filter that will strip off all query parameters when _ga is the first parameter shown.
I'm investigating Google Analtyics Goal tracking. I would like to append a query param to specific urls to indicate goal completion. Eg.
/some/path?goal=goal_name
I do not want to use the path part of the url for matching, only the query param. If I setup a destination regex matcher, will Google Analytics match the param part of the url? Eg.
goal=goal_name
Yes, it does. If you use regexp as match type remember to escape your question mark if you use the full url (i.e. /some/path\?goal=goal_name).
You can actually test this easily - the realtime reports have a "conversion" menu item that shows goal conversions immediately (not e-commerce-transactions, though). I usually create a separate view to test new goals and filters so I don't mess up my live data - I recommend you do the same.
In my Content Drilldown, when I go to the second page path level of one of my domains the link that displays duplicates the domain in the uri.
For example..
If I have the following:
events.company.com/
When I drill down the link above I will get:
/http:/
/
/some-directory/
When I click the Page dimension I will then get these links:
events.company.com/
events.company.com/http://events.company.com/index.php#
events.company.com/http://events.company.com/index.php#view/all
So you'll see that the links above like below is incorrect:
events.company.com/http://events.company.com/index.php#
It needs to be
events.company.com/index.php#
....but I don't why it's coming through like that and how to correct it.
Any suggestions?
Thanks
Actually, seems like someone followed the "right" instructions from GA help:
By default, the data in your reports includes only the Request URI and
not the domain name:
URL of page: http://www.example.com/foldername/page.html
Request URI: /foldername/page.html
Domain name: www.example.com
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
Note that creating URL rewrite filters like the one described above
can affect Analytics' ability to match your goals properly.
If you're using Analytics filters to rewrite your URLs, you need to
make sure that your goal settings reflect these changes. Like all
filters, URL-rewrite filters are applied to the raw data coming into
your account, before goals are processed. As a result, your goal and
funnel URLs should reflect the final, rewritten format of the URL.
https://support.google.com/analytics/answer/1012243?hl=en
However, it does messes data quite a lot. I believe this is an issue with GA, at least this documentation is misleading. Such filter also affects URL matching on Goals and funnels, so I would not recommend it.
I need to exclude from the analitycs tracking all the pages that contain the url parameter no_index
Example: http://www.mysite.com/page.php?product=54&no_index=1
All I have done it's putting into the filter pattern no_intex with nothing else.
Is that right or what would be a correct regexp for this?
This is a screenshot to clarify.
Many thanks for your help
Set your filter pattern to this:
\bno_index\b
I do the same thing in one of my accounts to remove all requests with a specific URL param and it works perfectly. Before saving your filter, click "Verify this filter" and it will show you the resulting effects so that you can verify it before saving.
Here is a screenshot of the exact configuration settings in Google Analytics that should work
Try this for your Filter Pattern: \/(.*)\&no\_index(.*)
The Request URI starts directly after the hostname.
So your example,
http://mysite.com (hostname)
/page.php?product=54&no_index=1 (Request URI)
So, your filter pattern, no_index, would look for no_index directly after http://www.mysite.com/no_index=1