• I’m very new to wordpress plugin editing so be kind ??

    I’ve created an admin setting page so that users can input their GA tracking code and I have it saved. I want to populate into their amp pages. Problem is I don’t know how to actually bring in the tracking code there. Here is the analytics code in the template where I need it to show up:

    <script async custom-element="amp-analytics"
        src="https://cdn.ampproject.org/v0/amp-analytics-0.1.js"></script>
    
    <amp-analytics type="googleanalytics" id="analytics1">
        <script type="application/json">
    {
      "vars": {
        "account": "UA-XXXXXXX-XX"
      },
      "triggers": {
        "trackPageview": {
          "on": "visible",
          "request": "pageview"
        }
      }
    }
        </script>
    </amp-analytics>

    I need the tracking code to pull the info from my options. I tried echoing it
    <?php echo $options['ga_account']; ?>
    but soon realized that you can’t really do that within the script. Can someone point me in the right direction? How do I pull an options value into the GA code above without breaking it?

    Like I said, I’m pretty new to this stuff.

  • The topic ‘AMP Google Analytics Plugin’ is closed to new replies.