question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

amp-analytics: Shared interpolation & ampState() URL variable

See original GitHub issue
  • Extract amp-analytics variable interpolation parsing (${var}) so it can be shared with another extension
  • Implement ${ampState(foo.bar)} variable that reads from amp-bind state

/cc @lannka

Issue Analytics

  • State:closed
  • Created 6 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

2reactions
lannkacommented, Jan 28, 2018

The variable code is here

expandTemplate is the main function. Right now you can ignore any filter related code as they are dead code and @calebcordry is cleaning up.

To be clear, this VariableService code is to provide recursive var substitution to JSON config:

{
  vars: {
    varA: "123",
    varB: "${varA}"
  },

  requests: {
     a: "${varA}&${varB}"
  }
}

if you do expandTemplate(requests.a), it will return a promise of 123&123.

Another way to do similar thing is to use urlReplacementService, of which the code is already in core. To get what you want, you will add an AMP_STATE macro to url-replacements-impl.js, and use it like:

{
  requests: {
   a: "AMP_STATE(x)"
  }
}

I think urlReplacementService might be a better choice at this point, despite its name does not sound relevant.

0reactions
stale[bot]commented, Dec 24, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed in 7 days if no further activity occurs. Thank you for your contributions.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Documentation: <amp-analytics> - amp.dev
The <amp-analytics> component specifies a JSON configuration object that contains the details for what to measure and ... The URL may include AMP...
Read more >
Is there a way to interpolate CSS variables with url()?
You can perform interpolation with most CSS functions, including rgba() (see an example here). In fact, interpolation is one of the main features...
Read more >
Google Analytics Client ID In AMP Pages | Simo Ahava's blog
Hey Guys, has anyone tried to set up the AMP Conversion Linker tag for cross-domain tracking and used an AMP variable to set...
Read more >
Parameters - Looker Studio Help - Google Help
How parameters share your data in reports ... While editing a report, you can use the +Add a parameter link in the data...
Read more >
How to track AMP Pages with Google Analytics 4 - David Vallejo
User Properties; Event Parameters. One of the most notorious misses on Google Analytics 4. Is the lack of AMP (Accelerated Mobile Pages) ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found