Guest Posted May 5, 2021 Share Posted May 5, 2021 Hi! I'd like to add the code below to each product page's header and at the checkout page so I can track conversions from Mailchimp. Normally I go into the wheel of every page>advance and add the code there but I can't see where to do that in product pages or checkout. Thank you for your help! <script id="mcjs">!function(c,h,i,m,p){m=c.createElement(h),p=c.getElementsByTagName(h)[0],m.async=1,m.src=i,p.parentNode.insertBefore(m,p)}(document,"script","https://chimpstatic.com/mcjs-connected/js/users/9fce44771f7d673adc52c2b87/cd709df9c2431ef7c5b608a10.js");</script> Link to comment
creedon Posted May 6, 2021 Share Posted May 6, 2021 (edited) Although I think this will work I can't be sure. I'm not all that familiar with MC. Add the following to Store Settings > Advanced > Page Header Code Injection for the store page. <script> /* begin add Mailchimp tracker code to product detail pages Version : 0.1d0 SS Version : 7.0 Template : Brine ( Aria, Blend, Cacao, Clay, Fairfield, Feed, Foster, Greenwich, Hatch, Heights, Hunter, Hyde, Impact, Jaunt, Juke, Keene, Kin, Lincoln, Maple, Margot, Marta, Mentor, Mercer, Miller, Mojave, Moksha, Motto, Nueva, Pedro, Pursuit, Rally, Rover, Royce, Sofia, Sonora, Stella, Thorne, Vow, Wav, West ) By : Thomas Creedon < http://www.tomsWeb.consulting/ > */ ( ( ) => { if ( ! document.getElementsByClassName ( 'ProductItem' ).length ) return; let script = document.createElement ( 'script' ); script.id = 'mcjs'; script.innerHTML = '! function ( c, h, i, m, p ) {' + 'm = c.createElement ( h ), ' + 'p = c.getElementsByTagName ( h ) [ 0 ], ' + 'm.async = 1, ' + 'm.src = i, ' + 'p.parentNode.insertBefore ( m, p )' + '}' + '( document, "script", "https://chimpstatic.com/mcjs-connected/js/users/9fce44771f7d673adc52c2b87/cd709df9c2431ef7c5b608a10.js" );'; document.getElementsByTagName ( 'head' ) [ 0 ] .appendChild ( script ); } ) ( ); /* end add Mailchimp tracker code to product detail pages */ </script> It may be possible to just throw the script you provided into the same place. Although that may cause noise in your tracking as that may track the product grid, category pages, ect. The checkout page can not be modified. It is a SS security feature. However you might be able to throw the script you provided into Settings > Advanced > Code Injection > ORDER CONFIRMATION PAGE. Let us know how it goes. Edited May 6, 2021 by creedon Find my contributions useful? Please like, upvote, mark my answer as the best ( solution ), and see my profile. Thanks for your support! I am a Squarespace ( and other technological things ) consultant open for new projects. Link to comment
Guest Posted May 6, 2021 Share Posted May 6, 2021 Thank you!! I've added the code and I'll let you know 🙂 Link to comment
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment