Viewing 3 replies - 1 through 3 (of 3 total)
  • Plugin Support James Osborne

    (@jamesosborne)

    Hi Asuf,

    Great question. If you’ve allowed Site Kit to insert your Analytics code this is automatically taken care of, as you’ve noticed there is a linker reference in your AMP URLs within your amp-analytics code. There is no option within Site Kit to modify the plugin inserted code.

    I’m trying to unify AMP and non-AMP sessions recorded with Amplitude by passing a user ID (on the same site. I have AMP disabled on some pages).

    If you prefer to manually insert your own Analytics code you can do so via alternate means. Site Kit can recognize your manually or third party plugin placed code, so you can avail of the plugins dashboards without allowing the plugin to place code. I don’t know your site URL but be sure you have regular Analytics code in your non AMP URLs and amp-analytics code in your AMP URLs.

    You can use conditional logic similar to the below if using AMP in paired mode (via the official plugins reader or transitional mode)

    <?php if ( function_exists( 'is_amp_endpoint' ) && is_amp_endpoint() ) : ?>
        <amp-analytics>...</amp-analytics>
    <?php else : ?>
        // regular Analytics code
    <?php endif; ?>
    Thread Starter asafm7

    (@asafm7)

    Thanks @jamesosborne

    Can the ability for adding additional custom linkers (via a filter maybe) be added as a feature request/suggestion?

    I feel like, in the long run, it would be better not to replace Site Kit’s native <amp-analytics> implementation.

    Plugin Support James Osborne

    (@jamesosborne)

    No problem at all.

    Can the ability for adding additional custom linkers (via a filter maybe) be added as a feature request/suggestion?

    You can submit a feature request to the plugins GitHub repository for the team to review if you wish. I’m happy to create one for you if you want to share more details.

    I feel like, in the long run, it would be better not to replace Site Kit’s native <amp-analytics> implementation.

    If using the suggested conditional logic the AMP plugin isn’t inserting any amp-analytics code. It will recognize that existing code, in which you can insert your own modifications to the AMP version.

    Let me know if you have any further questions on the above.

Viewing 3 replies - 1 through 3 (of 3 total)
  • The topic ‘Custom AMP analytics linkers’ is closed to new replies.