Action bar remain closed after first loading
-
Hi there,
Great plugin!I was wondering if its possible to set the action bar to remain closed after it’s initially loaded and been closed by the customer?
I’d like to keep the action bar available to customers via the ‘ig_close’ tab (for sale item links), but don’t want it to open every time they return to a page the action bar is on once they’ve initially closed it.Thank you for your help ??
Kind regards,
JP
-
You may choose not to load the action bar after it has once been loaded for the current session, for a day, week, month and so on.
Also, you may select the preference once the CTA is clicked.Kindly let me know if it works for you.
Hi Prathamesh,
Thank you for getting back to me ??I think this is actually what I’m wanting to do:
set cookie on action bar close
However I have absolutely no idea how to code javascript and set a cookie for the current session… any chance you’re able to provide me with the required code that I can copy and paste into the custom js code block of the action bar please?
Kind regards,
JPHi there,
Is there any chance you could paste the js code you used to resolve the ‘set cookie on action bar close’ topic?I have no idea how to set a cookie, I’ve tried various guides but can’t for the life of me get it to work.
Any help you can offer would be very much appreciated.
Kind regards,
JPHi @icegram,
Thank you for getting back to me.
I can’t seem to get this to work at all, if I delay time of action bar as -1 as described in the set cookie on action bar close the action bar doesn’t show at all.
With it set to ‘0’ the action bar shows but the javascript isn’t doing anything.Here’s the code I have in the custom code JS area:
<script type="text/javascript">jQuery( window ).on( “track.icegram”, function( e ,type, params ) { if(type !== undefined && type !== ” && type == ‘closed’ ){ //set your cookies here jQuery.cookie("test", 1); } } icegram.get_message_by_id({id}).show(); </script>
Can you let me know what needs to be changed to get this working please?
Thank you for your help!
Kind regards,
JPI didn’t bother installing the JQuery cookie plugin which would probably make this look a little more elegant but here’s my code which uses a helper function for cookie reading…
var icegram_messageid = 'nnnn'; //icegram postid+1 function helperf_readCookie(a, b) { b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)'); return b ? b.pop() : ''; } jQuery( window ).on( "track.icegram", function( e ,type, params ) { if(type !== undefined && type !== '' && type == 'closed' ){ var expiretime = new Date(new Date().getTime() + 15 * 60 * 1000).toUTCString();//stay closed for 15 mins document.cookie = "icegram_message_"+icegram_messageid+"_userclosed=1; expires="+expiretime+";path=/"; } }); //if visitor has not closed me recently, show icegram if ('1' != helperf_readCookie("icegram_message_"+icegram_messageid+"_userclosed")) { icegram.get_message_by_id(icegram_messageid).show(); }
Hi @feroxy,
Thanks for this, very much appreciate the help ??Unfortunately I can’t get this to work, settings wise I have the action bar set to display after 0 seconds (tried -1 but nothing shows up at all).
Nothing is selected in the display rules > retargeting section.I’ve placed your code in the custom code > js section like so:
<script type="text/javascript"> var icegram_messageid = 'nnnn'; //icegram postid+1 function helperf_readCookie(a, b) { b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)'); return b ? b.pop() : ''; } jQuery( window ).on( "track.icegram", function( e ,type, params ) { if(type !== undefined && type !== '' && type == 'closed' ){ var expiretime = new Date(new Date().getTime() + 15 * 60 * 1000).toUTCString();//stay closed for 15 mins document.cookie = "icegram_message_"+icegram_messageid+"_userclosed=1; expires="+expiretime+";path=/"; } }); //if visitor has not closed me recently, show icegram if ('1' != helperf_readCookie("icegram_message_"+icegram_messageid+"_userclosed")) { icegram.get_message_by_id(icegram_messageid).show(); } </script>
Any thoughts as to what I might be doing wrong?
Thanks again for your help ??
Kind regards,
JPMake sure you have that first line set to the correct id number. Look in the URL when editing the icegram for postid number and add 1
var icegram_messageid = 'nnnn'
Hi @feroxy,
I’m an idiot! Haha!
Thanks for the help ??Out of interest, do you know if it’s possible to have the open/close tab visible at all times?
If I right the code you sent through means once closed the action bar reopens again after 15 minutes… is that right? Ideally I’d like to have the open/close tab visible during this time so the customer has the option of reopening it and selecting an linked offer.
Any suggestions you might have will be very much appreciated.
Thanks again for all your help!
Kind regards,
JPit might be possible to do that with a customised action bar (not the air theme though). My very quick stab at this is below, although it’s not a very tidy implementation. If the close cookie is set, then subsequent page loads will show the icegram but immediately hide it which in the action bar case will still show the tab.
There’s probably a better way to do this, but its something to start from maybe…
var icegram_messageid = 'nnnn'; //enter the correct messageid here function helperf_readCookie(a, b) { b = document.cookie.match('(^|;)\\s*' + a + '\\s*=\\s*([^;]+)'); return b ? b.pop() : ''; } jQuery( window ).on( "track.icegram", function( e ,type, params ) { if(type !== undefined && type !== '' && type == 'closed' ){ var expiretime = new Date(new Date().getTime() + 15 * 60 * 1000).toUTCString();//stay closed for 15 mins document.cookie = "icegram_message_"+icegram_messageid+"_userclosed=1; expires="+expiretime+";path=/"; } else if(type !== undefined && type !== '' && type == 'shown' ){ document.cookie = "icegram_message_"+icegram_messageid+"_userclosed=0;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/"; } }); //if cookie is set, enable then immediately hide the icegram if ('1' === helperf_readCookie("icegram_message_"+icegram_messageid+"_userclosed")) { icegram.get_message_by_id(icegram_messageid).show(); icegram.get_message_by_id(icegram_messageid).hide(); } else //no cookie set, just show icegram message normally { icegram.get_message_by_id(icegram_messageid).show(); }
Hi @feroxy,
You are a legend!
Thank you so much for this ??Now so if I remove the time section will the action bar initially be open then just show the tab (quick open / close) as it now does and default to expire at the end of the session?
So remove this bit:
jQuery( window ).on( "track.icegram", function( e ,type, params ) { if(type !== undefined && type !== '' && type == 'closed' ){ var expiretime = new Date(new Date().getTime() + 15 * 60 * 1000).toUTCString();//stay closed for 15 mins document.cookie = "icegram_message_"+icegram_messageid+"_userclosed=1; expires="+expiretime+";path=/"; } else if(type !== undefined && type !== '' && type == 'shown' ){ document.cookie = "icegram_message_"+icegram_messageid+"_userclosed=0;expires=Thu, 01 Jan 1970 00:00:00 GMT;path=/"; } });
Or does it need some specific code to be set for the session?
I only ask as now that the tab will be available at all times there’s no need for action bar to pop up during the session.Also if there’s anyway to immediately hide rather than show then hide that would be ideal, however this is a great workaround and I really appreciate your help ??
Kind regards,
JPyou need to keep that bit but change expiretime to:
var expiretime = ''
to make it a session cookie
Hi @feroxy,
Perfect! Thanks again for all your help ??Kind regards,
JP
- The topic ‘Action bar remain closed after first loading’ is closed to new replies.