Skip to content

Instantly share code, notes, and snippets.

@lukebergen
Last active August 3, 2018 14:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save lukebergen/f5d47a72c711c7401096f7c44d65b27f to your computer and use it in GitHub Desktop.
Save lukebergen/f5d47a72c711c7401096f7c44d65b27f to your computer and use it in GitHub Desktop.
Reviewed GUP code
<% if Rails.env.production? || Rails.env.staging? %>
<script src="https://login.gcion.com/resources/kit/js/jqnoconflict.common.min.js"></script>
<script>
// Some stuff makes it to omniture via a window.utag_data object
// Some stuff comes through an object that window.stateManager.getActivePageInfo() returns
window.utag_data = {};
var pageInfo = {};
window.stateManager = {
getActivePageInfo: function() {
return pageInfo;
}
};
window.utag_data.page_domain = document.location.host;
window.utag_data.full_url = document.location.href;
window.utag_data.device = window.innerWidth > 979 ? 'desktop' : (window.innerWidth > 767 ? 'tablet' : 'mobile');
window.utag_data["cp.marketName"] = "reviewed.com";
var cat = "<%= current_website && current_website.category %>";
if (cat) {
window.utag_data.cst = cat + "/" + cat + "/" + cat;
pageInfo.ssts = "reviewed/<%= current_website.category %>";
}
<% if publish_on = (@article.try(:publish_on) || @prouct.try(:publish_on)) %>
window.utag_data.published_date = "<%= publish_on.strftime("%Y-%m-%dt%H:%M:%S.%N") %>"
<% end %>
<% if @article %>
window.utag_data.assetid = <%= @article.id %>;
window.utag_data.content_type = "<%= @article.has_classification?('review') ? 'review' : @article.resource_prefix %>";
window.utag_data.author = "<%= @article.authors.collect(&:name).join(",") %>";
pageInfo.headline = "<%= article_social_description(@article) %>";
pageInfo.assetid = <%= @article.id %>;
pageInfo.contenttype = "<%= @article.classifications.first %>";
<% if tks = taxonomy_keywords(article: @article, product: @product) and tks.any? %>
pageInfo.taxonomykeywords = "<%= tks.join(',') %>";
<% end %>
<% end %>
<% if @product %>
window.utag_data.brand = "<%= @product.brand_name %>";
<% if range = price_range(@product) and !range.blank? %>
window.utag_data.price_range = "<%= range %>"
<% end %>
<% end %>
require(['gdp-usf/kit/js/user_factory_def', 'gdp-usf/ui/js/jquery'], function(UserFactory, jQuery) {
var userFactory = new UserFactory(JSON.parse('<%= raw(configatron.gup.options) %>')),
gupRootDomain = '<%= configatron.gup.root_domain %>',
gupUAID = '<%= configatron.gup.uaid %>';
userFactory.fetch(gupRootDomain, gupUAID, function(user) {
window.utag_data = (typeof window.utag_data === 'object') ? window.utag_data : {};
window.utag_data['gup_anonid'] = user.data.response.anonymousId;
if (user.data.response.insights) {
window.utag_data['gupInsights_doLookALike'] = user.data.response.insights.doLookALike || '';
window.utag_data['gupInsights_benefitSegment'] = user.data.response.insights.benefitSegment || '';
}
jQuery.getScript('https://tags.tiqcdn.com/utag/gci/reviewed.com/prod/utag.js');
});
});
window.require = undefined;
window.define = undefined;
</script>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment