Hub Hack: Bypass CTAs on Gated Items With a URL Parameter

Follow

Details

  • Type: Javascript
  • Placement: Body Bottom
  • Notes: Allows you to automatically dismiss the CTA gating an Item when it is accessed from a link that contains a specified URL parameter:
    • You can copy and paste the whole code block below without making any changes. By default, the parameter name that triggers the CTA bypass is set to paramName — we recommend changing this to a parameter name of your choice, but it can also be left as-is.
    • Once the Hub Hack is in place, you can bypass the CTA by adding ?paramName (or whatever parameter name you chose) to the end of the URL of a gated Item in your Hub. For example, if the Item My Book is gated with a CTA, the CTA would appear if you go to hub.mycompany.com/ebooks/my-book, but not if you visit hub.mycompany.com/ebooks/my-book?paramName.

 

Code

<script>
/* start bypass CTA function code */
$(window).on('load', bypassCTA ); //must fire the bypassCTA function after everything loads, including the CTA

function bypassCTA(){
var hideWithThisParam = 'paramName';
/*change paramName to the URL parameter value you want to use to hide the CTA */

var params = {};


$.each(location.search.substr(1).split('&'), $.proxy(function(idx, pair) {
if (pair === '') return;


var parts = pair.split('=');
this[parts[0]] = parts[1] && decodeURIComponent(parts[1].replace(/\+/g, ' '));
}, params));


$.each(params, function(idx, val){
if(idx == hideWithThisParam) {
$('.blocking-cta').removeClass('blocking-cta');
$('.hide-embed').removeClass('hide-embed');
$('.block-cta').remove();
$('.possible-block').removeClass('possible-block');
}
});}

/* end bypass CTA function code */
</script>
0 out of 0 found this helpful

Comments

0 comments

Please sign in to leave a comment.