What is the purpose of Access URL Variables in AMP? Where and how are they used?

522 Views Asked by At

Can you please provide an explanation of Access URL Variables in AMP, their purpose and how and where they are used?

For example, can you please provide a step by step example of how you integrated them into an amp-story?

the official amp-access sample for demos of first-click-free and view counting

1

There are 1 best solutions below

1
On BEST ANSWER

From the amp-access documentation:

When configuring the URLs for various endpoints, the Publisher can use substitution variables. The full list of these variables are defined in the AMP Var Spec. In addition, this spec adds a few access-specific variables such as READER_ID and AUTHDATA.

Access URL variables allow you send vital information regarding the user or the session by including them in the URL. The best example would be READER_ID, which can be used to uniquely identify each user.

For eg. consider you have set up authorization endpoint in your amp-access configuration as follows :

https://publisher.com/amp-access.json?rid=READER_ID&url=SOURCE_URL

Then authorization call from your page will go with the variables READER_ID and SOURCE_URL substituted as follows:

https://publisher.com/amp-access.json?rid=amp-s90UCBp2NixS3-wpVmKsSw&url=http%3A%2F%2Flocalhost%3A8000%2Famp.html&__amp_source_origin=http%3A%2F%2Flocalhost%3A8000

Now your backend server can identify users uniquely by checking the url parameter rid and get the source url from url parameter url. You can use all of the Access URL variables similarly. For more info refer AMP-Access Docs and AMP-Access Example