The steps described below will show you how to target users who purchased the same term within a specific time period more than once. You could target users who purchased this term for example more than 5 times.
-
Save a cookie for a user when they converted on a particular term for the 1st time with the use of the
checkoutCompletecallback. -
Save a cookie for a user when they converted on a particular term for the 2nd time.
-
Set the expiration date of the cookie to X days (e.g. 30 days ) on both cookies.
You can use this sample code to set the cookies programmatically:
tp.push(["addHandler", "checkoutComplete", function(conversion){ // First If checks if user has converted on specific term && checks if they previously converted on this same term if(conversion.termConversionId === 'YOUR_TERM_ID' && document.cookie.indexOf('_pc_boughtTermXFirstTime=true');){ //Sets expiration data var date, expires, days; days = 30; //Sets the exiration days for 30 date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); expires = "; expires="+date.toGMTString(); document.cookie = "_pc_boughtTermXSecondTime=true" + expires; // Second If checks if user has converted on a specific term && if 1st If is false, it assigns boughtTermXFirstTime cookie to the user }else if(conversion.termConversionId === 'YOUR_TERM_ID'){ //Sets expiration data var date, expires, days; days = 30; //Sets the exiration days for 30 date = new Date(); date.setTime(date.getTime()+(days*24*60*60*1000)); expires = "; expires="+date.toGMTString(); //Sets the cookie document.cookie = "_pc_boughtTermXFirstTime=true" + expires; } }]);This code would need to be put in your Piano integration code (either via the Composer embed code or directly on your website).
Please note, that the cookies you're setting need to start with a
_pc_string, so they can be targeted also in other Experiences. -
Don't show the offer to users that have bought the same term multiple times when the cookie
boughtTermXSecondTimeis NOT present. If this cookie is not available it means, that the user has purchased the term only once or never. -
Show your offer to users when they bought this term two or more times when the cookie
boughtTermXSecondTimecookie is present.