Connecting user from AMP to nonAMP pages - analytics

Looking at google's AMP documentation, seems like clientID is a great way to store a unique user id. But how can I translate that through my regular non amp page? If a user sees an AMP page and got a clientID, then they performed some operation which led them to land on non AMP page. As I don't have access to old cookies on google's cache domain, how can I relate AMP clientID with my new generated clientID on NON AMP page?

Creating a proxy as shown in https://github.com/andreban/amp-publisher-sample/commit/c455a2d117a8899dcb201f93e17889f4d2681cd3 should work for this case. Note that the example is for google analytics but you can easily use the technique for other providers

Related

How to remove URL Queries in Google Tag Manager for any tag (not only Google Analytics)?

I found a few articles and answers how to strip queries from URLs sent to Google Analytics. How about other services, like Facebook or Hotjar? Is there any way to send them clean URLs?
I aim to maximize the website visitors' privacy and to avoid accidental data leaks.
That does not depend on Google Tag Manager, but on the respective tracking tags.
It works for Google Analytics because the "location" field is explicitly set and can be overridden. Other tags might not offer this as a feature - e.g. many marketing tags infer the page location from the referrer instead of having an option to set the value. Since the referrer is sent in a http header as part of the request for the marketing pixels, it is outside the domain of GTM to manipulate.

Create a post on facebook on users behalf using new Sharing Products feature

My scenario:
I have an application within which users keep their own journals. For some of the journal records, i want to enable them to post to their facebook timeline.
It was rather straightforward with an old api (obtaining token and posting) but with a new Sharing Product, it seems impossible because its intended to use ograph data and backlink from facebook post to the page within the app but since the journal post itself is for logged user only, i don't see a way how could it work.
So, the question is:
How to enable users to share (actually, "replicate" is more accurate word) content from their authorization protected area within my application to their facebook timeline?
PS.
I am aware of solutions like: Auto post (user behalf) on facebook but that's an old api.
You can not create new content like this any more in any automated way, you can only let your users share links.
But you can point the Share button to any URL you like (parameter href), it does not have to be that of the current page.
Facebook will follow whatever you have set as og:url or canonical, so that would have to be the version without authorization then.
That would also be the URL that users clicking on the link in that post would be redirected to.

Firebase Data Structuring

we are building two Ionic apps at the startup I work for. We saw the benefit of rapid development that Firebase offers and we decided to use it as our backend. We are building hotel booking apps for users (people that want to search and book hotels) and for the hotels so that they can manage their bookings. The first app for the users is done and we have all our data and authentication rules stored at a Firebase Data URL. We are about to start building the second app meant for the hotels and we have some serious questions:
Should we use the same Firebase Data URL for the hotel app or should we create another one? If we use the same Firebase Data URL, that means data for the hotels and the users will be mixed and the URL will handle authentication for the entities.
Please we would really appreciate your input and opinions on best practices on how to do this. Thank you.
There's no reason why you cannot use the same URL
myHotelAppRootNode
Users
someUser
someUser
Hotels
someHotel
someHotel
Then set up the rules to restrict access.
We have data and users in the same url in our beta app and it's not causing any mixing of data; as long as the rules are correct (which can be a bit challenging).
Using two URL's may slightly uncomplicate the rules per, but then you have multiple authentication points since it's two URL's. So say, once a user authenticated with a single URL model, they would then have access to hotel data directly whereas with two you have to auth them once, and then the app would need to auth them again to the second URL.

Use Oauth 2.0 in google app engine with java

I would like to use Oauth 2 for an application in Google App Engine with Java, but I dont find any good example of that use, I would be very thankful if somebody could help me please, it is something frustrating dont find good examples, thnak you.
My 2c is avoid oauth2 libraries. Of course opinions may vary, but for me they provide very leaky abstractions, so you end up being dragged into understanding oauth by the back door. For me at least, taking an hour to read the the two pages that tell you all you need to know, and carefully avoiding all the others, will get you where you want to be.
In simple terms, the steps are :-
Call the auth URL with your app/client ID and the scopes you require. Include the "email" scope.
Google will walk the user through login, and (if the first time through) authorisation dialogues
Eventually the browser will redirect back to your oauthcallback url, and pass you an auth code
Call google to convert the auth code to a refresh token. This will also return the user's google ID and an access token.
Store the user ID in your session so you can identify the user subsequently
Persist the refresh token alongside the google user id in a database
On subsequent visits...
If you have the google user id in the your session, you can retrieve the refresh token from your database and use it to generate access tokens as you need them.
If you do NOT have the google user id in your session, go through the steps above. This time, google will NOT prompt the user for authorisation (since it's already authorised), and the refresh token will be blank (since you already have one stored).
Everything you need to know is within the oauth playground page. If you click through the buttons, you will see that it is following the steps I outlined above.
You then need to deal with the possible error situations, eg
user declines permission
user withdraws permission
google expired the refresh token (happens a lot) so you need to re-auth
timeouts
The two pages you need to read are :-
https://developers.google.com/accounts/docs/OAuth2WebServer and the oauth playground at https://developers.google.com/oauthplayground/
Trust me, as long as you know how to form a URL, store a refresh token (it's just a string) and parse a JSON response, then everything you need is on those pages. Except ...
all the documentation skips over the need to preserve the user ID in your session so you know who it is that is accessing your app. If you're on AppEngine, you may be confused by the appengine sample code which uses a separate appengine login. Ignore it. You will be using oauth to authenticate the user so the appengine stuff doesn't apply and is somewhat confusing.
It's actually much simpler than some of the documentation would lead you to believe, and like I said, imho the leaky libraries don't help.
I'm trying to do exactly the same thing and I agree - it is extremely hard to find a good example of this.
I did find this youtube video however and I think it would help: https://www.youtube.com/watch?v=tVIIgcIqoPw.
Its from Google and it is called Getting Started with Google APIs. The last segment of the video deals with authentication.
There are several OAuth 2 client and server libraries for Java listed on this page: http://oauth.net/2/
Here's quick-start documentation for using Apache Otlu: https://cwiki.apache.org/confluence/display/OLTU/OAuth+2.0+Client+Quickstart
If you're accessing a Google API (as a client), you can use the Google client library for Java, which does OAuth as well as API set-up: https://code.google.com/p/google-api-java-client/

How to add the user name in the url for a Chrome extension?

I am working on a chrome bookmarking extension with google app engine as the backend. I am the only user now but I thought that if in the future there are other users the url needs to include the user name for the extension to interact with the backend. So I was thinking to change
http://ting-1.appspot.com/useradminpage
to
http://ting-1.appspot.com/user_name/useradminpage
where "user_name" is the gmail user id.
But I looked at twitter url and I see that they have
http://twitter.com/#!/user_name/
What is the purpose of "#!"? Is my scheme good enough in this case?
The # in a URL signifies the 'fragment identifier'. Historically this has been used to identify a part of a document identified by an 'anchor' tag, but recently webapp developers have begun to use it to pass information about the page state to Javascript code running in the page. This is used because it's possible for Javascript code to modify the fragment of the current page without causing the page to reload - meaning it can update as you browse through the webapp, and go right back to where you were when you reload the page.
The fragment is not sent to the server when the browser loads a page, so Twitter's server just sees a request for twitter.com; it's up to the Javascript code in the page to examine the fragment and determine what to do after that.
In your particular case, assuming you're using the App Engine User service to authenticate users, you have a number of options for how to distinguish users in your URLs:
Use their email address. In theory this can change, and users may not want their address in a URL they will share. If the URLs are private, this is more or less a moot point.
Use their user_id. This is opaque and reveals no useful information about the user, so it's safe, but it's also meaningless and hard to remember.
Let users pick a nickname for their URLs, like Facebook and other services do, on a first-in, first-served basis.

Resources