ampproject / ampproject/amphtml

Allow AMP_GEO url substitution in <a> tags

Open
#35,482 4 comments 0 reactions 1 assignee Claimed by @kristoferbaxter View on GitHub
Stale Type: Feature Request WG: components
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### Description

I have a use case where I need to provide the country code as part of an anchor tag. I can't figure out the country server side since it's coming from the amp cache.

amp-geo already allows url variable substitution, but is not applied to anchor tags.

Alternatively, we could also add the AMP_GEO variable to the `amp-link-rewriter` extension. My link is for a 3rd party so you could imagine they're using country code as part of an affiliate link as part of tracking. (e.g., https://example.com?country_code=US) which would make a post to something like branch.io before redirecting you).

### Alternatives Considered

I know amp-geo can set the country code in amp-state on page load. So I thought maybe I could try using that to dynamically generate the href. However, amp-bind does not take into affect until after a user gesture. I still don't think that would completely solve my use case, but that was an alternative I considered.

### Additional Context

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.