Home > Shopify Tutorials > To add affiliate links to your Shopify store

How to add affiliate links to your Shopify store?

Last updated: March 01, 2024
This article has been written and researched by our expert Avada through a precise methodology. Learn more about our methodology

Sam

Author

Daniel

Researcher

To build trust with customers and increase sales, adding affiliate links to your Shopify store is a smart choice. There is no denying that we live in an ever-growing and changing affiliate marketing market. Affiliate Marketing started growing from the 90s of the last century. In 2017, it accounted for 15% of the entire digital advertising market. The value of the US market is expected to grow to US $7 billion by 2020. Do you really understand Affiliate Marketing and Affiliate links? The following article will clarify these two concepts and guide you how to add affiliate links to your Shopify store.

What is affiliate marketing?

Affiliate marketing is a form of promoting products or services of the supplier, which is the company whose products or services want through the websites of partners promoting goods and services. End-user. Partners making money online receive a commission when a user visits the partner’s website to manage and perform actions that the supplier wants from the end-user, such as Purchasing, registering to use services, fill in the information, etc.

How to add affiliate links to your Shopify store

In essence, Affiliate (Performance marketing base on Partnership) is that advertisers rely on publishers to promote their products. A publisher can run all forms of digital marketing and they receive a commission when a user purchases through their link. To maximize the purchasing desire of users, publishers will run advertising campaigns based on traffic platforms such as their websites, blogs, social networks or user data.

Why should you join Affiliate marketing?

  • No need to own products or services.
  • No need to worry about shipping or customer care.
  • It can participate in generating income with a low initial cost.
  • Ability to practice marketing skills through the promotion of products and services.
  • Enjoy attractive commission and always be paid on time.

The affiliate link of a product is a specific URL that contains the ID or username of the link. In affiliate programs, advertisers use affiliate links to record user traffic and the number of orders successfully sold through that affiliate link. They will be sent to the website of the marketing network where they will statistically and confirm successful orders and pay commissions to marketers.

During the sale process, there will be times when products are only made by order or they are currently unavailable. You will want to replace the “Add to cart button” with an affiliate link. This will help keep customers comfortable and keep your sales going on seamlessly.

Below, I will show you in detail how to replace the Add to cart button with an affiliate link. However, the steps will vary for the type of theme you are using. Therefore, first, go to the theme’s Edit code page to determine it. If you see files in the Section directory, you are using a sectioned theme. Vice versa, if you don’t see a file in that directory, a non-sectioned theme is the answer. In addition, the non-sectioned theme was released before October 2016. So if you use the theme published after that time, it will not be a non-sectioned theme. After you’ve determined what type of theme you’re using, be sure to move to the correct section to follow the instructions.

For Section themes

Create a new product template

  • Step 1: Click Online Store in the left-hand menu from your admin page. Then, go to Themes.

How to add affiliate links to your Shopify store

  • Step 2: Make sure to find out the theme you expect it to be edited. Afterward, select the Actions button and tap on the Edit code.

How to add affiliate links to your Shopify store

  • Step 3: Choose the Add a new template in the Templates field.

How to add affiliate links to your Shopify store

  • Step 4: In this step, you will need to create the product template. Choose product in the first drop-down menu. Then, name your template requires-contact. Click the Create template to finish creating a new template.

How to add affiliate links to your Shopify store

  • Step 5: Look for the following code:

{% section 'product-template' %}

After you’ve found it, replace it with:


{% section 'product-template-requires-contact' %}

This code is used to link your new product template with a new section you will create in the next section.

  • Step 6: Tap on Save to complete.

Create a new product section

  • Step 1: Choose the Add a new section in the Sections field.

How to add affiliate links to your Shopify store

  • Step 2: You can create a new section now. Name your section product-template-requires-contact and tap Create section then.

How to add affiliate links to your Shopify store

  • Step 3: In this step, you need to delete all of the default code in the file. It should be empty so that you can move to the next step.

How to add affiliate links to your Shopify store

  • Step 4: Select the product-template.liquid file in the Section field and copy all the default code of the file to your clipboard.

How to add affiliate links to your Shopify store

  • Step 5: Back to the new product-template-requires-contact.liquid file and paste the code into that file.

How to add affiliate links to your Shopify store

  • Step 6: Finally, select the Save button.

How to add affiliate links to your Shopify store

Hide the Add to cart button

  • Step 1: From the product-template-requires-contact.liquid file, make sure to look for the HTML code for the Product form of your product page. A cool tip for you to find it faster is you can search for the word form in the file.

How to add affiliate links to your Shopify store

  • Step 2: After you’ve found the code, wrap it in Liquid {% comment %} and {% endcomment %} tags. This is used to stop showing the code in your store. However, if you expect to change your new template later, you can put it back effortlessly.

Below is an example for Narrative:


{% comment %}
{% include 'product-form' %}
{% endcomment %}


  • Step 3: Choose the Save button to have it done.

Above, you’ve hidden the Add to cart button successfully. Now, I will walk you through how to add the content you want to display instead.

An affiliate link:

As mentioned above, affiliate links bring good benefits to your business and help you earn commissions. To add an affiliate link, you can do as the following:

  • Below the Liquid {% endcomment %} tag which you’ve added in the previous section, add the following code: ```

Please contact us if you are interested in this product.

You can **replace `shop.email` with an affiliate link**. When your customers click on it, they will be redirected to your partner’s website.

- Remember to tap on `Save` before leaving.

**Contact form**:

Apart from an affiliate link, adding a contact form is highly recommended. You can do this by copying the code from your theme’s contact page template. Then, do these steps:
- Open the `page.contact.liquid` file from the `Templates` field.
- Look for the Liquid `{% form 'contact' %}` tag in that file.
- Now, you need to copy all the code from the Liquid `{% form 'contact' %}` tag down to the Liquid `{% endform %}` tag. Note that it must include the Liquid form tags.
- Back to the `Templates` directory and open your new `product.requires-contact.liquid` file then.
- Make sure to paste the code into a new line below the Liquid `{% endcomment %}` tag.
- Next, wrap the code which you’ve just pasted in HTML div tags. The class attribute is used to ensure that your contact form will render accurately on the page. 

- Paste the following code on a new line above the `{% form 'contact' %}`:

``` - Paste the following code on a new line below the `{% endform %}`: ```

- Click `Save` to finish.

#### Assign your new template to a product
Now that the template is completed, you need to assign it to all of your items for which you expect to hide the `Add to cart` button. Take these simple steps below.

- Tap on the `Products` section in the admin page. Then, choose the `All products`. 
- Select the product’s name that you expect the `Add to cart` button to be hidden.
- Under `Theme templates`, there is a drop-down called `Template suffix`. Make sure to choose your new `requires-contact` template.
- Don’t forget to tap on `Save`. 

### For Non-section themes

#### Create a new product template
- **Step 1**: Click `Online Store` in the left-hand menu from your admin page. Then, go to `Themes`.

![How to add affiliate links to your Shopify store](https://cdn4.avada.io/media/shopify/jlKBoTV.jpg)

- **Step 2**: Make sure to find out the theme you expect it to be edited. Afterward, select the `Actions` button and tap on the `Edit code`.

![How to add affiliate links to your Shopify store](https://cdn4.avada.io/media/shopify/YHrn97K.jpg)

- **Step 3**: Choose the `Add a new template` in the `Templates` field.

![How to add affiliate links to your Shopify store](https://cdn4.avada.io/media/shopify/q7tDkW3.jpg)

- **Step 4**: In this step, you will need to create the product template. Choose `product` in the first drop-down menu. Then, name your template `requires-contact`. Click `Create template` to finish creating a new template.

![How to add affiliate links to your Shopify store](https://cdn4.avada.io/media/shopify/vsSZdCD.jpg)

#### Hide the Add to cart button
- **Step 1**: From your new `product.requires-contact.liquid` file that you’ve made, search for the HTML code for the `Add to cart` button. To find it easier, press `Ctrl + F` and enter the word `cart`. 

You should know that the codes for the `Add to cart` button of different themes are also different. Therefore, look for tags such as <input> or <button> and text like `add-to-cart`, `Add to cart`, or `AddToCart`.

Here is an example of the `Add to cart` button code for Debut: 

<button type=”submit” name=”add” id=”AddToCart-{{ section.id }}” {% unless current_variant.available %}disabled=”disabled”{% endunless %} class=”btn product-form__cart-submit{% if product.options.size == 1 and product.variants[0].title == ‘Default Title’ %} product-form__cart-submit–small{% endif %}”> {% unless current_variant.available %} {{ ‘products.product.sold_out’ | t }} {% else %} {{ ‘products.product.add_to_cart’ | t }} {% endunless %} </button>



- **Step 2**: After you’ve found the code, wrap it in Liquid `{% comment %} and {% endcomment %}` tags. This is used to stop showing the code in your store. However, if you expect to change your new template later, you can put it back effortlessly.

Below is how the modified code would look like (for Debut):

{% comment %} <button type=”submit” name=”add” id=”AddToCart-{{ section.id }}” {% unless current_variant.available %}disabled=”disabled”{% endunless %} class=”btn product-form__cart-submit{% if product.options.size == 1 and product.variants[0].title == ‘Default Title’ %} product-form__cart-submit–small{% endif %}”> {% unless current_variant.available %} {{ ‘products.product.sold_out’ | t }} {% else %} {{ ‘products.product.add_to_cart’ | t }} {% endunless %} </button> {% endcomment %}


`Caution`: **Don’t comment out the `<form>` tags for your product page**. Because, if your comment tags surround `<form>` or `</form>` tags, your clients might experience errors when seeing your product page. 

- **Step 3**: Choose the `Save` button to have it done.

#### Add an affiliate link or contact form
Above you’ve hidden the `Add to cart` button successfully. Now, I will walk you through how to add the content you want to display instead. 

**An affiliate link**: 

As mentioned above, affiliate links bring good benefits to your business and help you earn commissions. To **add an affiliate link**, you can do as the following:

- Below the Liquid `{% endcomment %}` tag which you’ve added in the previous section, add the following code:

Please contact us if you are interested in this product.

You can replace `shop.email` with an affiliate link. When your customers click on it, they will be redirected to your partner’s website.

- Remember to tap on `Save` before leaving.

**Contact form**:

Apart from an affiliate link, adding a contact form is highly recommended. You can do this by copying the code from your theme’s contact page template. Then, do these steps:

- Open the `page.contact.liquid` file from the `Templates` field.

- Look for the Liquid `{% form 'contact' %}` tag in that file.

- Now, you need to copy all the code from the Liquid `{% form 'contact' %}` tag down to the Liquid `{% endform %}` tag. Note that it must include the Liquid form tags.

- Back to the `Templates` directory and open your new `product.requires-contact.liquid` file then.

- Make sure to paste the code into a new line below the closing `</form>` tag.

- Next, wrap the code which you’ve just pasted in HTML div tags. The class attribute is used to ensure that your contact form will render accurately on the page. 

- Paste the following code on a new line above the `{% form 'contact' %}`:

``` - Paste the following code on a new line below the `{% endform %}`: ```

```

  • Click Save to finish.

Assign your new template to a product

Now that the template is completed, you need to assign it to all of your items for which you expect to hide the Add to cart button. Take these simple steps below.

  • Tap on the Products section in the admin page. Then, choose the All products.

How to add affiliate links to your Shopify store

  • Select the product’s name that you expect the Add to cart button to be hidden.

How to add affiliate links to your Shopify store

  • Under Theme templates, there is a drop-down called Template suffix. Make sure to choose your new requires-contact template.

How to add affiliate links to your Shopify store

  • Don’t forget to tap on Save.

How to add affiliate links to your Shopify store

Shopify best affiliate apps

How to add affiliate links to your Shopify store

We probably all understand the impact of affiliate marketing and the great ability to make money from this method. In order to help you catch up on new marketing trends and support your business to approach this form of effective advertising and sales as quickly as possible, we have carefully prepared useful information in the Shopify Affiliate Apps article. This post will help you learn about 17+ Best Shopify Affiliate Apps, their advantages and choose the most appropriate application for your business. Do not hesitate to click it now.

Final words

It’s hard to deny the amazing benefits of affiliate marketing. It’s a pleasure when preparing this article about How to add affiliate links to your Shopify store to assist you. With simple and concise steps, you will be able to do this successfully. Do not forget to visit the article Shopify Affiliate Apps to choose for your online store the best app that helps you solve your affiliate marketing issues simply, with Affordable prices including completely free applications.

Related Posts:


Sam Nguyen is the CEO and founder of Avada Commerce, an e-commerce solution provider headquartered in Singapore. He is an expert on the Shopify e-commerce platform for online stores and retail point-of-sale systems. Sam loves talking about e-commerce and he aims to help over a million online businesses grow and thrive.