Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ console.log(amp) // amp string
## Options

name | default value | note
------------ | ------------- | -------------
------------ | ------------- | -------------

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can you add description about the new option here?

cwd|`.`|image / styles base path
gaConfigPath| |`amp-analytics` config json path for [google analytics](https://www.ampproject.org/docs/analytics/analytics-vendors)
serviceWorker| |attributes of [amp-install-serviceworker](https://www.ampproject.org/docs/reference/components/amp-install-serviceworker) <br/> e.g. `src`, `data-iframe-src`
Expand Down Expand Up @@ -115,11 +115,11 @@ This library ...
- also add `layout="responsive"` attribute
- replace `<iframe />` with `<amp-iframe />`
- add `<amp-analytics />`
- only support google analytics
- supports different types of vendors (https://www.ampproject.org/docs/analytics/analytics-vendors)
- also removed regular google analytics tag
- it's optional
- it's optional
- add [amp-install-serviceworker](https://www.ampproject.org/docs/reference/components/amp-install-serviceworker)
- it's optional
- it's optional
- replace all a tag links which destination is original site with absolute url which starts with http[s]
- original url comes from canonical's href attribute
- e.g. `<a href="/test">` is replaced with `<a href="https//original-url.com/test">`
Expand Down
2 changes: 1 addition & 1 deletion lib/googleanalytics/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ const googleanalytics = ($, options) => {
if (options.gaConfigPath) {
const config = utils.getRelativeFile(options.gaConfigPath, options.cwd)
const $script = $('<script async custom-element="amp-analytics" src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js" />')
const $config = $(`<amp-analytics type="googleanalytics"/><script type="application/json">${config}</script></amp-analytics>`)
const $config = $(`<amp-analytics type=${options.vendor}><script type="application/json">${config}</script></amp-analytics>`)

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

IMO, vender option might be ambiguous. 🤔 User may think what kind of vender it is.

How about analyticsVendor ?

$('body').prepend($config)
$('head').prepend($script)
}
Expand Down