{"templateId":"markdown","sharedDataIds":{"sidebar":"sidebar-sidebars.yaml"},"props":{"metadata":{"markdoc":{"tagList":[]},"redocly_category":"Integrations","type":"markdown"},"seo":{"title":"Google Accelerated Mobile Pages Amp","description":"Treasure Data Product Documentation · Collect and Unify · Segment and Activate · Experiment and Analyze · Decisioning Automate with AI Scale and Trust.","siteUrl":"https://docs.treasuredata.com","lang":"en-US","llmstxt":{"hide":false,"sections":[{"title":"Table of contents","includeFiles":["**/*"],"excludeFiles":[]}],"excludeFiles":[]}},"dynamicMarkdocComponents":[],"compilationErrors":[],"ast":{"$$mdtype":"Tag","name":"article","attributes":{},"children":[{"$$mdtype":"Tag","name":"Heading","attributes":{"level":1,"id":"google-accelerated-mobile-pages-amp","__idx":0},"children":["Google Accelerated Mobile Pages Amp"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Treasure Data can track users with Google Accelerated Mobile Pages (AMP). The ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.ampproject.org/docs/ads_analytics/analytics-vendors#treasure-data"},"children":["Treasure Data AMP component"]}," makes it easy to send data from AMP components easily."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["This component automatically collects default properties and track customers. Treasure Data is one of the official Analytics vendors supported by the ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.ampproject.org/docs/ads_analytics/analytics-vendors#treasure-data"},"children":[{"$$mdtype":"Tag","name":"em","attributes":{},"children":["amp-analytics"]}," component"]},"."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"prerequisites","__idx":1},"children":["Prerequisites"]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Basic knowledge of Treasure Data"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["Basic knowledge of JavaScript / HTML / AMP Script"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"getting-started","__idx":2},"children":["Getting Started"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you’re new to ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.ampproject.org/"},"children":["Google AMP"]},", go through their ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.ampproject.org/docs/getting-started/"},"children":["Quickstart"]}," guide."]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["When you have your own AMP page up and running, include the ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["amp-analytics"]}," component before the closing ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":[]}," tag. ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://www.ampproject.org/docs/reference/components/amp-analytics"},"children":["amp-analytics"]}," is an AMP component to capture analytics data from an AMP document."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"<script async custom-element=\"amp-analytics\" src=\"https://cdn.ampproject.org/v0/amp-analytics-0.1.js\"></script>\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Use ",{"$$mdtype":"Tag","name":"code","attributes":{},"children":["<amp-analytics type=\"treasuredata\" id=\"treasuredata\">"]}," to automatically collect page views, as follows:"]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"<amp-analytics type=\"treasuredata\" id=\"treasuredata\"><script type=\"application/json\">  {    \"vars\": {      \"host\": \"in.treasuredata.com\",      \"writeKey\": \"YOUR_WRITE_ONLY_APIKEY_IS_HERE\",      \"database\": \"YOUR_DATABASE_NAME\"    },    \"triggers\": {      \"trackPageview\": {        \"on\": \"visible\",        \"request\": \"pageview\",        \"vars\": {          \"table\": \"pageviews\"        }      }    }  }</script></amp-analytics>\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["The API Key can be retrieved from Treasure Console in your Profile page. It’s recommended to use write-only API key for SDKs. Each event will fire off asynchronously."]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"default-parameters-collected","__idx":3},"children":["Default Parameters Collected"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["A few parameters are automatically collected with each page view and event call."]},{"$$mdtype":"Tag","name":"ul","attributes":{},"children":[{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_client_id – 1st party cookie id"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_charset – character set"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_language – browser language"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_color – screen color depth"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_screen – screen resolution"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_viewport – viewport size"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_title – document title"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_url – source document url"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_user_agent – browser user agent"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_host – document’s sourcehost"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_path – document’s sourcepathname"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_platform – browser platform"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_referrer – document referrer"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_ip – request IP (server)"]},{"$$mdtype":"Tag","name":"li","attributes":{},"children":["td_global_id - 3rd party cookie id"]}]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"custom-parameters","__idx":4},"children":["Custom Parameters"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["If you want to set the custom parameters, specify them in extraUrlParams with using ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/ampproject/amphtml/blob/main/docs/spec/amp-var-substitutions.md"},"children":["AMP HTML URL Variable Substitutions"]},"."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"<amp-analytics type=\"treasuredata\" id=\"treasuredata\">\n<script type=\"application/json\"> \n{\"vars\": { \"host\": \"in.treasuredata.com\", \"writeKey\": \"YOUR_WRITE_ONLY_APIKEY_IS_HERE\",      \"database\": \"DATABASE_NAME\" }, \"triggers\": { \"trackPageview\": { \"on\": \"visible\",\"request\": \"pageview\", \"vars\": { \"table\": \"pageviews\" }, \"extraUrlParams\": {\"example_param1\": \"123\",          \"example_param2\": 456}}}}\n</script>\n</amp-analytics>\n","lang":"javascript"},"children":[]},{"$$mdtype":"Tag","name":"Heading","attributes":{"level":2,"id":"custom-events","__idx":5},"children":["Custom Events"]},{"$$mdtype":"Tag","name":"p","attributes":{},"children":["Above JSON is based on ",{"$$mdtype":"Tag","name":"MarkdownLink","attributes":{"href":"https://github.com/ampproject/amphtml/blob/main/extensions/amp-analytics/amp-analytics.md"},"children":["amp-analytics spec"]},". You can specify where event triggers will fire with ",{"$$mdtype":"Tag","name":"em","attributes":{},"children":["on"]}," attribute. The example below will collect events when the website visitors click the elements."]},{"$$mdtype":"Tag","name":"CodeBlock","attributes":{"data-language":"javascript","header":{"controls":{"copy":{}}},"source":"<amp-analytics type=\"treasuredata\" id=\"treasuredata\">\n  <script type=\"application/json\">\n    {\"vars\": {\"host\":\"in.treasuredata.com\", \"writeKey\": \"YOUR_WRITE_ONLY_APIKEY_IS_HERE\", \"database\": \"DATABASE_NAME\"},\"triggers\": {\"trackPageview\": {\"on\": \"visible\",\"request\": \"pageview\",\"vars\": {\"table\": \"pageviews\"},\"extraUrlParams\": {\"foo\": \"123\"}},\"trackClick\": {\"on\": \"click\",\"request\": \"event\",\"vars\": {\"table\": \"events\"},\"extraUrlParams\": {\"type\": \"click\",\"bar\": 789 }}}}\n  </script>\n</amp-analytics>\n","lang":"javascript"},"children":[]}]},"headings":[{"value":"Google Accelerated Mobile Pages Amp","id":"google-accelerated-mobile-pages-amp","depth":1},{"value":"Prerequisites","id":"prerequisites","depth":2},{"value":"Getting Started","id":"getting-started","depth":2},{"value":"Default Parameters Collected","id":"default-parameters-collected","depth":2},{"value":"Custom Parameters","id":"custom-parameters","depth":2},{"value":"Custom Events","id":"custom-events","depth":2}],"frontmatter":{"seo":{"title":"Google Accelerated Mobile Pages Amp"}},"lastModified":"2026-06-01T09:09:59.000Z","pagePropGetterError":{"message":"","name":""}},"slug":"/int/google-accelerated-mobile-pages-amp","userData":{"isAuthenticated":false,"teams":["anonymous"]},"isPublic":true}