ampproject / ampproject/amphtml

amp-analytics not setting cookies when using self-hosted runtime

Open
#38,437 3 comments 0 reactions 0 assignees View on GitHub
P3: When Possible Stale Type: Bug WG: analytics
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### Description

amp-analytics not setting cookies when using self-hosted runtime

### Reproduction Steps

## Observed Behavior:

amp-analytics blocks setting cookies when using a self-hosted runtime.

1. Go to https://www.bedbathandbeyond.com/amp/wm-optimized/store/s/shower
2. Observe self-hosted runtime tag
3. ![Screen Shot 2022-09-06 at 8 44 45 PM](https://user-images.githubusercontent.com/1224514/188785300-af3049b1-0c49-4c5d-a258-233f6e50ce37.png)

4. Observe that "current == proxy" when using self-hosted runtime and checkOriginForSettingCookie() throws error.
5. ![Screen Shot 2022-09-06 at 8 47 58 PM](https://user-images.githubusercontent.com/1224514/188784925-928baaeb-f9d4-4f23-99a0-26720513e666.png)
6. Cookie setting error then leads to a cascade of linker tracking errors and malformed beacons.
7. ![Screen Shot 2022-09-06 at 8 50 58 PM](https://user-images.githubusercontent.com/1224514/188785035-932b6c59-4ed1-4078-9569-6964888f4ad2.png)

## Expected Behavior:

amp-analytics sets cookies to track user journey. The page below is not using self-hosted runtime. Cookies work as expected with linker configurations and _ga cookie tracking.

https://www.bedbathandbeyond.com/amp/store/s/shower

### Relevant Logs

_No response_

### Browser(s) Affected

_No response_

### OS(s) Affected

_No response_

### Device(s) Affected

_No response_

### AMP Version Affected

012208242209000, 012109272305001

Contributor guide

Open the contributing guide

Research direction

Reproduce the issue with the self-hosted and non-self-hosted Bed Bath & Beyond AMP URLs, then inspect checkOriginForSettingCookie() and the amp-analytics cookie/linker flow. Done means cookies are set with the self-hosted runtime and linker tracking no longer produces cascading errors or malformed beacons.

Written by the indexing model from the issue text.

Assessment

Tech stack
javascript
Domain
analytics
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.