Skip to content

Commit

Permalink
Merge pull request #3 from voxmedia/nw-async-concert-ads
Browse files Browse the repository at this point in the history
Async concert script from Lenny's suggested change
  • Loading branch information
lsirivong authored Jan 13, 2022
2 parents 44a82ed + 9f8e3ac commit a547d07
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# v2.2.0

- Add conditional rendering of AMP url to <head> in layout.erb
- Initialize ConcertAds when ready

# v2.1.0

Expand Down
11 changes: 10 additions & 1 deletion template/source/layouts/_concert.erb
Original file line number Diff line number Diff line change
@@ -1,12 +1,21 @@
<script>
const installConcertAds = () => {
let concertAds = new ConcertAds({
slug: '<%= data.content.entry.frontend.adUnitSlug %>',
dfpVariables: {
entry_id: ['<%= data.content.entryId %>'],
keywords: "<%= data.content.title.gsub('"', '') %>"
}
});

concertAds.loadRemoteConfig('<%= data.content.community.concertConfigUrl %>').then(() => {
concertAds.install();
});
</script>
}

if (!window.ConcertAds) {
window.addEventListener('concertAdsReady', installConcertAds);
} else {
installConcertAds();
}
</script>
2 changes: 1 addition & 1 deletion template/source/layouts/layout.erb
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@
<%= javascript_include_tag 'site' %>
<script src='https://www.googletagservices.com/tag/js/gpt.js' async></script>
<script src='https://c.amazon-adsystem.com/aax2/apstag.js' async></script>
<script src='<%= data.content.community.concertLibraryUrl %>'></script>
<script src='<%= data.content.community.concertLibraryUrl %>' async></script>
<%= partial('layouts/_analytics') %>
</head>
<body>
Expand Down

0 comments on commit a547d07

Please sign in to comment.