Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
E
ETH Google Analytics for AMP
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Iterations
Requirements
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Locked files
Deploy
Releases
Model registry
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
Repository analytics
Code review analytics
Issue analytics
Insights
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
This is an archived project. Repository and other project resources are read-only.
Show more breadcrumbs
WP Plugins
ETH Google Analytics for AMP
Merge requests
!1
WIP: Initial release
Code
Review changes
Check out branch
Download
Patches
Plain diff
Closed
WIP: Initial release
develop
into
master
Overview
2
Commits
20
Changes
1
Closed
Erick Hitter
requested to merge
develop
into
master
9 years ago
Overview
2
Commits
20
Changes
1
Expand
0
0
Merge request reports
Viewing commit
e0d85b58
Prev
Next
Show latest version
1 file
+
8
−
4
Inline
Compare changes
Side-by-side
Inline
Show whitespace changes
Show one file at a time
e0d85b58
Improve how component script is included
· e0d85b58
Erick Hitter
authored
9 years ago
Props @mjangda for the pointer.
eth-amp-analytics-wp.php
+
8
−
4
Options
@@ -97,7 +97,7 @@ class ETH_AMP_Analytics_WP {
*/
public
function
action_wp_loaded
()
{
if
(
!
empty
(
$this
->
get_option
(
'property_id'
)
)
)
{
add_
action
(
'amp_post_template_
head
'
,
array
(
$this
,
'
action
_amp_post_template_
head'
),
5
);
// Must appear before the AMP JS library
add_
filter
(
'amp_post_template_
data
'
,
array
(
$this
,
'
filter
_amp_post_template_
data'
)
);
add_action
(
'amp_post_template_footer'
,
array
(
$this
,
'action_amp_post_template_footer'
)
);
}
}
@@ -107,12 +107,16 @@ class ETH_AMP_Analytics_WP {
*/
/**
*
Add
component script
to header
*
Include
component script
*
* Must appear before AMP JS library, per https://developers.google.com/analytics/devguides/collection/amp-analytics/
*/
public
function
action_amp_post_template_head
(
$scripts
)
{
?>
<script
async
custom-element=
"amp-analytics"
src=
"https://cdn.ampproject.org/v0/amp-analytics-0.1.js"
></script>
<?php
public
function
filter_amp_post_template_data
(
$data
)
{
if
(
!
isset
(
$data
[
'amp_component_scripts'
][
'amp-analytics'
]
)
)
{
$data
[
'amp_component_scripts'
][
'amp-analytics'
]
=
'https://cdn.ampproject.org/v0/amp-analytics-0.1.js'
;
}
return
$data
;
}
/**
Loading