AdWords is now Google Ads. Our new name reflects the full range of advertising options we offer across Search, Display, YouTube, and more. Learn more

Analytics
1.6K members online now
1.6K members online now
Dive into multiple domain (Cross/Sub) tracking, implementing Ecommerce and Enhanced Ecommerce, setting up Event tracking, and Universal Analytics code.
 
Guide Me
star_border
Reply

Get unit visitors on a specific url between dates

Visitor ✭ ✭ ✭
# 1
Visitor ✭ ✭ ✭

Hi!

 

I have a website with 2 domains, like domain1.com and domain2.se. Same site but different languages. Now, i want to get unit visitors on each user profile page on this site, like domain1.com/[USERNAME]/* and domain2.se/[USERNAME]/*.
I want to get the total visitors on both domains day by day between 2 days, like 2016-06-28: 10, 2016-06-29: 9 ...
Is this possible to segment with google analytics? If so how. I will use the google analytics api to get the result.
This is what i have to track the visits:

(function (i, s, o, g, r, a, m) {
            i['GoogleAnalyticsObject'] = r; i[r] = i[r] || function () {
                (i[r].q = i[r].q || []).push(arguments);
            }, i[r].l = 1 * new Date(); a = s.createElement(o),
            m = s.getElementsByTagName(o)[0]; a.async = 1; a.src=g; m.parentNode.insertBefore(a, m);
        })(window, document, 'script', '//www.google-analytics.com/analytics.js', 'ga');

        ga('create', 'UA-XXXXXXX', 'auto', { allowLinker: true });
        ga('require', 'linker');
        ga('linker:autoLink', ['domain1.com', 'domain2.se']);
        ga('send', 'pageview');
1 Expert replyverified_user

Re: Get unit visitors on a specific url between dates

Rising Star
# 2
Rising Star
Hi Marcus,

Yes it's possible. All you need to do is pull in hostname as a secondary dimension, use it in a custom report, or create a segment for each domain using hostname as the dimension.

Best,

Theo Bennett
Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn

Re: Get unit visitors on a specific url between dates

[ Edited ]
Visitor ✭ ✭ ✭
# 3
Visitor ✭ ✭ ✭

Hi Theo!

Thanx for your answer. What i want to get is unit unique visits on /[USERNAME ]. What domain is not relevant in this case. The problem is that /[USERNAME] has subpages, so i want to get total unique visits on /[USERNAME]/*.
Is that posible to do with google analytics api? If so, how?
([USERNAME] is the name of the profile)

 

I try this:

https://www.googleapis.com/analytics/v3/data/ga?ids=ga:XXXXXXX&dimensions=ga:pagePath&metrics=ga:pageviews&filters=ga:pagePath==/demo&start-date=2016-06-20&end-date=2016-06-29&max-results=50

but i get, Login Required

Re: Get unit visitors on a specific url between dates

Rising Star
# 4
Rising Star
Hi Marcus,


You can do this in the UI, but if you want to sue the API I suggest you build your query using the API Query Explorer or the Google Sheets Plug in.


https://ga-dev-tools.appspot.com/query-explorer/?csw=1


https://developers.google.com/analytics/solutions/google-analytics-spreadsheet-add-on


The query explorer is a good proof of concept at it will give you the API query URI. If you are building out a tool to hit the API for you can plug that in and build in your service account or OAuth 2 authentication. If you only need the data on occasion, the sheets plug-in should work.


Best,


Theo
Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn

Re: Get unit visitors on a specific url between dates

Visitor ✭ ✭ ✭
# 5
Visitor ✭ ✭ ✭
Hi Theo!

Thanx for your answer. What i want is to have the [USERNAME] dynamic. I want to display for the user how many visitors the member has on the profile page.
If a user visit /demo = 1 visit on the profile. If another user visit /demo/guestbook, 1 visit on the profile page.
Now, i want to display for the member(the profile page owner), a list of visits the last 7 days like this:
2016-06-22: 1
2016-06-23: 0
2016-06-24: 2
2016-06-25: 5
2016-06-26: 0
2016-06-27: 1
2016-06-28: 5

I want from my website, call google analytics api, and recive this. But how? Is that possible to get?

Re: Get unit visitors on a specific url between dates

Rising Star
# 6
Rising Star
Hey Marcus,

I see. Well you need to handle it programmatically. That is pass in the filter param matching what you are looking for into the API. I would still be a little concerned about collecting username in GA. It's going to split your pages in the content reports (unless you rewrite it) and I would be a little concerned about PII. If you have a lot of users you'll also hit table row limits and have cardinality in the content reports. If you set the custom dimension to some sort of unique hashed id that would be something on which you could also query the API and pull back the data by ga:date.

-Theo
Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn

Re: Get unit visitors on a specific url between dates

Visitor ✭ ✭ ✭
# 7
Visitor ✭ ✭ ✭
Hi Theo,

Thanks. Maybe it's better to find another solution for this problem? I think its hard to get what i want from GA? Use piwik to store only profile visits is maybe a solution?

Re: Get unit visitors on a specific url between dates

Rising Star
# 8
Rising Star
Piwik will allow you to use PII; that said, you can do this in GA - it's just best to not have user names etc in the data and cleaner to have this in a custom dimension.

-Theo
Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn

Re: Get unit visitors on a specific url between dates

[ Edited ]
Visitor ✭ ✭ ✭
# 9
Visitor ✭ ✭ ✭

Yes, in Piwik it's really simple. I only create a new website for each user-profile in piwik. Then each profile gets its own piwik-id, which i can use to query visits on a specific profile page.

It's not so easy with Google Analytics to recive the same.

 

So, instead of, www.domain.com/demo i should send, www.domain.com/profile/1 to GA?

Re: Get unit visitors on a specific url between dates

Rising Star
# 10
Rising Star
Hi Marcus,

So, instead of, www.domain.com/demo i should send, www.domain.com/profile/1 to GA?

- I'm not sure where you are going with this Smiley Sad All I'm suggesting is to not have the username in the URI and if you do to rewrite it with a virtual pageview to keep it clean and stay clear of PII issues. You can easily set something that identifies the user in a custom dimension (still no PII).

By the way, you can use the navigation summary tab in Behavior>>Site Content>> All Pages to see this today; I'm just suggesting that you may have PII issues and it's not a scalable solution as your user base grows very large.

Custom Dimensions and USER ID is built for what you are trying to do; custom dimensions are more flexible and you could actually use both which would give you insights into cross device behavior.

Best,

Theo Bennett




Analytics Evangelist at MoreVisibility | Contact Me
Connect on LinkedIn