Jump to content

Adding custom code to product page and checkout page

Recommended Posts

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
  • Replies 2
  • Created
  • Last Reply

Top Posters In This Topic

Popular Days

Top Posters In This Topic

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.


    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 */

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 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

Create an account or sign in to comment

You need to be a member in order to leave a comment

  • Create New...

Squarespace Webinars

Free online sessions where you’ll learn the basics and refine your Squarespace skills.

Hire a Designer

Stand out online with the help of an experienced designer or developer.