Created
August 7, 2012 20:05
-
-
Save apendleton/3288888 to your computer and use it in GitHub Desktop.
Gigya integration snippet
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
(function() { | |
var insertScript = function(url) { | |
var elem = document.createElement('script'); | |
elem.src = (document.location.protocol == "https:" ? "https://cdns" : "http://cdn") + ".gigya.com/js/" + url; | |
elem.async = true; | |
elem.type = "text/javascript"; | |
$('script').eq(0).before(elem); | |
} | |
window.onGigyaServiceReady = function(type) { | |
if (type !== "socialize") return; | |
insertScript("gigyaGAIntegration.js") | |
var ua = new gigya.socialize.UserAction(); | |
var head = $('head'); | |
var url = head.find('meta[name=og:url]').attr('content'); | |
ua.setLinkBack(url); | |
ua.setTitle(head.find('meta[name=og:title]').attr('content')); | |
ua.setDescription(head.find('meta[name=og:description]').attr('content')); | |
ua.addMediaItem({ | |
type: 'image', | |
href: url, | |
src: head.find('meta[name=og:image]').attr('content') | |
}); | |
var params = { | |
containerID: 'share-buttons', | |
iconsOnly: true, | |
layout: 'horizontal', | |
noButtonBorders: true, | |
shareButtons: 'facebook,twitter', | |
shortURLs: 'never', | |
showCounts: 'none', | |
userAction: ua | |
}; | |
gigya.socialize.showShareBarUI(params); | |
} | |
insertScript("socialize.js?apiKey=XXXXXXXXXXXXXX") | |
})(); | |
</script> |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment