Shopify Quick-Start Guide

Start using Confection with Shopify in a few simple steps.

Issues? Questions? Feedback? Leave a comment. Already have a Confection account? Skip to step three. New to Confection? Learn more here.

Get Started

Step One

If you haven’t already, create a Confection account. If you already have a Confection account, log in.

Continue to Step 2

Step Two

Click “My Account” (or “Set Up My Account” if you’re accessing your account for the first time). Enter your contact information, the domain(s) on which you want to use Confection, and select one of our two data storage options. Then, click “Save Changes.”

Continue to Step 3

Step Three

Click "Install Confection" (If you're accessing your account for the first time, this will be the default screen.) Next, select "PHP" to download the relevant scripts.

Continue to Step 4

Step Four

Inside your Confection account, click "Install Confection" > "Downloads." Then, click the "PHP" tile to save the necessary files to your desktop. Unzip them, and upload cable.php to a server or PaaS/cloud service that can execute scripts (Elastic Beanstalk, Digital Ocean, Heroku, &c). (Simply uploading cable.php to a CDN that hosts static files won't work.) You'll need the link to this script later in this process.

At this point you have two options. If neither applies to you, skip ahead to the "Get Your Custom Code" step.

"I'm hosting cable.php and my site on different domains. (Or I'm using cable.php on several different domains.)"

If you're hosting cable.php on the same domain as your website (eg., domain.com/cable.php and domain.com), there's no need to worry about this information. Skip ahead to the next step.

If you're hosting cable.php at a domain or sub-domain that's different from your website (eg., sub.domain.com/cable.php and anotherdomain.com), please add this code to the top of cable.php. Put it below <?php and above $write_key = 0;.

Use the second line to whitelist your primary domain (the domain on which you installed Confection). Just replace domain.com with your site's domain. For example, if you're hosting cable.php at sub.domain.com and you installed Confection at anotherdomain.com, you'd replace domain.com with anotherdomain.com

If you're installing Confection on multiple domains, comment out the second line, uncomment the fourth, and enter a comma-separated list of domains. For example, if you're hosting cable.php at sub.domain.com and you installed Confection at anotherdomain.com and yetanotherdomain.com, you'd replace domain.com and xyz.net with anotherdomain.com and yetanotherdomain.com

"I want (or need) to ensure only my sites can write data to my Confection account."

For most users, Confection's standard security protocols are sufficient. However, advanced users, sites that handle sensitive information, and compliance-driven organizations may want to harden their Confection accounts against unauthorized data ingestion. If this doesn't apply to you, skip ahead to the next step.

If it does, we offer each account the option to use an API write key. This write key will ensure no domain you haven't added to your dashboard can write data to your Confection account.

To activate your write key, visit the API key section of your dashboard. Click "Generate" to generate your key, and copy it. Find $write_key = 0; in cable.php. (It's at the top.) Then, replace 0 with your actual key.

Please note, once you activate your account's write key, the current key must appear in your cable.php file. There's no going back. Going forward, Confection will not be able to add data to your account unless your current key appears in your cable.php file.

Next, use our code-builder tool to set your privacy options, choose your banner position, and even upload your own logo. Click the button below to get started.

Get Your Custom Code

Make sure you add your complete, secure (ie., https:// included) URL you created earlier in this step (eg., https://link.to.script.com/cable.php) to the "Cable URL" field. To avoid mixed content errors, make sure you load cable.php over https:// vs. http://

Next, log into Shopify. In your store, select "Actions" > "Edit code." Then, open the Layout folder and, finally, theme.liquid. (If you've made modifications to your theme, the default theme.liquid may not be the right place to add this code. The goal is to add the code above to your theme's default layout file.)

In the theme.liquid file, look for the opening and closing head tags (<head> </head>). Paste the custom header code you just generated above the </head> tag.

Next, look for the opening and closing body tags (<body> </body>). Paste the following code anywhere between your site's <body> </body> tags.

Lastly, if it doesn't already, make sure the top-level domain you created earlier in this step (eg., the link.to.script.com portion of https://link.to.script.com/cable.php) appears in your account's list of authorized domains. To find this list, click "My Account" inside your Confection account.

Tracking Conversion (Checkout) Events

If you'd like to use Confection to track conversion (checkout) events, do the following:

  1. Copy the following code, and save it as a local file (eg., confection.js):
  1. In Shopify, visit Content > Files, and upload the file.
  2. Verify that the script appears at https://your-shopify-url.com/cdn/shop/files/confection.js Just replace your-shopify-url.com with your Shopify store URL.
  3. Next, visit Settings > Customer Events.
  4. Click, "Add Custom Pixel."
  5. Paste this code in the code editor. Note, you can replace lines 1-7 with the custom header code you created earlier in this step. If you'd like to use the sample below instead, use the cable URL you set up earlier in this process (line 1), and be sure to replace with your Confection account number (line 2).
  6. On line 9, replace your-shopify-url.com with your Shopify store URL. And, on line 13, define your custom event name by replacing EventNameHere with whatever name you like (eg., CheckoutEvent or CustomerCheckout).
  1. Lastly, click “Save” and, then, “Connect.”

That's it. You're done.



“I have some questions.”

Step Five: Send Confection Data Anywhere

After installing Confection, start sending data to any number of different endpoints.

"I'd like some help with this."

Next Steps

Install & Integrate Elsewhere

Find Other Quick-Start Guides

"I have some questions."

Contact Us

"I want to see this."

Share It

Discussion

Questions or comments about using Confection with Shopify? Leave them below.

"Please contact me. I have some questions."

You can also use the chat app in the lower right corner.