aalan

Adobe Analytics getTimeParting plug-in – Update

If you are using the plugin of version older than 5.0 then you have to worry about s.tpDST because v5.0 onwards Adobe removed the need for s.tpDST parameter to be set as daylight savings start/end dates will now be detected automatically.

Resurfacing an issue with older versions of the getTimeParting plug-in that made quite the stir at the beginning of every year. If you took the easy route and edited the plug-in code instead of upgrading to the latest version, you’ll want to make sure that you make those same edits again before January 1.

More information on this topic can be found in this forum thread: https://experienceleaguecommunities.adobe.com/t5/adobe-analytics-discussions/important-notice-for-those-using-the-gettimeparting-plug-in/td-p/391631

The post is old but we have to use the same logic, the latest version is v6.3

In case you are on older version and want to stick to it then you need to make some edits.

/*Time Parting */
//time parting configuration for Australia

s._tpDST= {
2014='4/6,10/5',
2015='4/5,10/4',
2016='4/3,10/2',
2017='4/2,10/1',
2018='4/1,10/7',
2019='4/7,10/6',
2020='4/5,10/4',
2021='4/4,10/3',
2022='4/3,10/2',
2023='4/2,10/1',
2024='4/7,10/6',
};

To implement from scratch, you can use the following code. This needs to be implemented on the s code through the Tool config settings.

Tracker variable name: s
Code Type: Custom
s_code Storage Location : Manageds_code content

var s = _satellite.getToolsByType('sc')[0].getS();

s.usePlugins=true

s.doPlugins=function(s) {

/* Plugin: getTimeParting 4.0 */

s.getTimeParting=function(z,h){var s=this,od=new Date("1/1/2000");if(od.getDay()!=6||od.getMonth()!=0)return"Data Not Available";else{var H,M,D,U,ds,de,tm,da=["Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Saturday"],mo=["January","February","March","April","May","June","July","August","September","October","November","December"];d=new Date;z=z?z:0;z=parseFloat(z);h=h?h:"n";if(s._tpDST&&typeof s._tpDST[d.getFullYear()]!="undefined"){var dso=s._tpDST[d.getFullYear()].split(/,/);ds=new Date(dso[0]+

"/"+d.getFullYear());de=new Date(dso[1]+"/"+d.getFullYear());if(h=="n"&&d>ds&&d<de)z=z+1;else if(h=="s"&&(d>de||d<ds))z=z+1}d=d.getTime()+d.getTimezoneOffset()*6E4;d=new Date(d+36E5*z);H=d.getHours();M=d.getMinutes();M=M<10?"0"+M:M;U="AM";if(H>=12){U="PM";H=H-12}if(H==0)H=12;D=d.getDate()<10?"0"+d.getDate():d.getDate();tm=H+":"+M+" "+U;return"year="+d.getFullYear()+" | month="+mo[d.getMonth()]+" | date="+D+" | day="+da[d.getDay()]+" | time="+tm}};

/* Timeparting Daylight Savings Begin/End Dates */

s._tpDST={2015:"3/8,11/1",2016:"3/13,11/6",2017:"3/12,11/5",2018:"3/11,11/4",2019:"3/10,11/3",2020:"3/8,11/1",2021:"3/14,11/7",2022:"3/13,11/6",2023:"3/12,11/5",2024:"3/10,11/3",2025:"3/9,11/2",2026:"3/8,11/1",2027:"3/14,11/7",2028:"3/12,11/5",2029:"3/11,11/4",2030:"3/10,11/3"};

var gTP = s.prop7 = s.getTimeParting(5.5,"n");

var day = gTP.split("|")[3].split("=")[1] ;

var hour = gTP.split("|")[4].split("=")[1] ;

s.eVar7 = hour + "|" + day ;

}

Related Posts

Leave a comment

You must login to add a new comment.

[wpqa_login]