Join us today @ 1pm EDT for an AMA with 2H Media: Holiday Marketing for Your Shopify Store and have your marketing questions answered by marketing experts 2H Media | Plus watch the 2H Media AMA Livestream on Twitch!

Re: Why recommended products have extra params in URL?

Why recommended products have extra params in URL?

Yu727
Excursionist
38 0 10
I am showing the recommended products in PDP.
{%- for product in recommendations.products -%}
<li class="product">
<a href="{{ product.url }}">
...
</a>
</li>
{%- endfor -%}
But the products have long URLs.
https://[store]/products/red-hat?pr_prod_strat=copurchase&pr_rec_pid=2264152113206&pr_ref_pid=2264163287094&pr_seq=uniform
Is it possible to show products with a short URL like https://[store]/products/red-hat ?
Replies 30 (30)

Vellir
Shopify Partner
146 32 40

Hi Yu727,

 

Those parameters are there for tracking purposes. I don't recommend removing them as you wouldn't know how the recommendations are performing.

 

You can find mentions to these parameters in the links bellow:

 

https://help.shopify.com/en/themes/development/recommended-products

 

https://help.shopify.com/en/themes/development/recommended-products/using-json-api#tracking-conversi...

- Looking for a Wishlist? Try First Wish

- Shopify Merchants, manage your new arrivals with Newr

- Shopify Developers, if you're looking into selling your app to focus on other projects, drop me a line.
Bigjjjim
Shopify Partner
12 0 3

Hi Vellir, 

 

Is this feature automatically added on venture theme? 


I have hundreds of new pages on my google search consoles with similar Url as the one in the question. I am not using any recommendation features from my theme or from the app. I was surprised to see 1k+ new urls in my search console. I believe it makes my other main pages slower to get indexed...

Any insights?

Cheers

danilobega93
Visitor
1 0 0

Same here @Vellir Hundreds of URLs with that parameters are indexed. What's the solution?

frankymartin
Shopify Partner
32 0 20

Hi @Vellir 

 

The URLs with parameters from Recommendations section are a problem for SEO. Any idea how to link the clean URL of the products? 

 

Thanks

frankymartin
Shopify Partner
32 0 20

Hi, I have tried to do noindex that urls but it is not working. I added to theme.liquid:

Captura de pantalla 2022-09-29 120148.png

Any help about it?
Vellir
Shopify Partner
146 32 40

My reply above is answering the original question only: "Why Recommended Products Have Extra Params In URL?"

 

Also, based on some other posts above some themes can also modify the URLs.

 

However, it seems most people here want to remove the extra parameters regardless.

 

It doesn't look like there's a universal solution to remove the query parameters but I'm happy to help everyone individually (or at least try). Please PM me your details if you wish me to have a look. 

 

We can share the solution here if find one.

- Looking for a Wishlist? Try First Wish

- Shopify Merchants, manage your new arrivals with Newr

- Shopify Developers, if you're looking into selling your app to focus on other projects, drop me a line.
fanwer
Tourist
5 0 7

Is it possible for us to set the "Disallow: / xxxxx" in our robots.txt file to avoid search consoles crawling this long and meaningless URL by adding a robots.txt file or altering it via google's robots testing tools?

 

If this is feasible, then what should it be "Disallow: / xxxxxx"?

 

A Shopify Player
fanwer
Tourist
5 0 7

This is an update for the piece of code, and the piece finally works for me. See the screenshot from Google Search Console. 

screenshot from GSC.png

 

The code is here:

 

{%- if canonical_url="*seq=uniform" -%}
<meta name="robots" content="noindex, nofollow">
{%- endif -%}

 

Put the code at the end of your theme.liquid file.

A Shopify Player
frankymartin
Shopify Partner
32 0 20

Great!! So, the codes to insert are:

 

In theme.liquid (to do noindex):

 {%- if canonical_url="*seq=uniform" -%}
<meta name="robots" content="noindex, nofollow">
{%- endif -%} 

 

{% if handle contains 'seq=uniform' %}
<meta name="robots" content="noindex, nofollow">
{% endif %}

 

In robots.txt (to block crawler):

{%- if group.user_agent.value == '*' -%}
{{ 'Disallow: /products/*?pr=*' }}
{%- endif -%}

frankymartin
Shopify Partner
32 0 20

Sorry, I did a mistake copying the code. The good code will be;

 

{% if handle contains 'seq=uniform' %}
<meta name="robots" content="noindex">
{% endif %}

Johnny__Taylor
Shopify Partner
3 0 0

Hello Frankymartin,

have you found any solution with this code ?
I have facing same problem with extra url parameters.

J.Taylor
mrhandsome
Tourist
9 0 0

Hey @frankymartin 

 

I will try this code snippet in my theme.liquid. did you already find out if its working properly?

 

I mean this one:

{% if handle contains 'seq=uniform' %}
<meta name="robots" content="noindex">
{% endif %}

Fabrizio4
New Member
4 0 0

I have the same issue but I am not a developer and I don't know how to fix it. Does anyone have a solution? I have hundreds of canonical URLs, and I am trying to work on SEO.

ContentDrive
Shopify Partner
8 0 0

Hi guys,

Think i might have a solution for this.

You can disallow these pages using the robots.txt file which helps to control which pages are crawled on your site.

You can search for robots in your theme files to locate this or If you haven't created one follow the instructions below:

  1. From your Shopify admin, click Settings > Apps and sales channels.

  2. From the Apps and sales channels page, click Online store.

  3. Click Open sales channel.

  4. Click Themes.

  5. Click Actions, and then click Edit Code.

  6. Click Add a new template, and then select robots.

  7. Click Create template.

Then in the robots.txt add a disallow rule for these parameter:

Disallow: /?pr_prod=

 
Hope that helps - let me know if you need any more info!
Shopify SEO Specialist
Content Drive - Shopify SEO Agency
Alexis_Théry
Shopify Partner
15 0 5

Sorryy but its not working

batfink1989
Shopify Partner
5 0 8

I know I'm late to answer this, but I wouldn't advise necessarily just blocking the URLs in robots.txt file as you're losing a lot of internal linking. Ideally, you'd find a way to remove the params from the URL (I'm currently looking into doing this myself). That way you keep the internal linking but remove the proper canonical error in GSC.  You can track 'recommended products' performance using GA4 and create an event specifically for recommended product clicks.

Highbeam
Shopify Partner
3 0 3

I agree with @batfink1989 . Looking forward for the solution.

batfink1989
Shopify Partner
5 0 8

The solution to this varies from theme to theme but it's something along the lines of changing {{ product.url }} to {{ product.url | split: "?" | first }} in the relevant theme file that contains the 'recommended products' liquid.

I've changed a few of these now and they were in different places and named different things (e.g. one file was named "card-product.liquid" while another was named "product-thumbnail.liquid"), but you can work out where you need to change this with a bit of digging.

 

By changing this code, the URL that is generated no longer includes the recommended product params but still includes the link to the canonical product URL, meaning you get a clean-looking URL and some 'brownie points' for internal linking too.

Hopefully, this helps. I'd be happy to help anyone who needs some guidance, whether that's to do with this specifically or the GA4 tracking that you may want to implement afterwards.

batfink1989
Shopify Partner
5 0 8

@Highbeam hope this helps 👍

Djani
Tourist
11 0 1

Hi, well done for that! I'm a seo and that would be the ideal solution. 

However, in my case I can't find this {{ product.url }} in my recommendation section. If you have any tips on what to change here..

https://ibb.co/kHCswDs
https://ibb.co/MR0r30z

Wooki
Tourist
4 0 3

Hi @Djani , 

I found it in my product-card.liquid file. 

I change : 
<div class="card-wrapper">
<a href="{{ card_product.url | default: '#' }}" class="full-unstyled-link">
<span class="visually-hidden">{{ card_product.title | escape }}</span>
</a>

By :

<div class="card-wrapper">
<a href="{{ card_product.url | default: '#' | split: "?" | first }}" class="full-unstyled-link">
<span class="visually-hidden">{{ card_product.title | escape }}</span>
</a>

 

My problem is solved

 

thx @batfink1989 

 

frankymartin
Shopify Partner
32 0 20

It works for me!! I use DAWN theme.

Univers-d-Ange
Excursionist
21 0 2

What a pain !
But thank you for your hints , I found the solution for my theme!

FOR DAWN 12

- Go to card.product.liquid file
- Search for "card_product.url"
- There should be at line 113, 157 and 235
- Replace all by "card_product.url | split: "?" | first"
- That's it
Now you have clean URL in your featured products section links

Univers d'Ange : La boutique des Anges
Découvrez nos bagues d'Ange ou nos pendentifs d'Ange
batfink1989
Shopify Partner
5 0 8

@Djani , sorry for the late reply. Did you manage to get this sorted?

Djani
Tourist
11 0 1

No I cannot find anything in the theme where I could find something like that to delete.

Alexis_Théry
Shopify Partner
15 0 5

HI @batfink1989 , thanks for your solution.

In my case i have this kind of code ( i guess i not expert on liquid) . I found it on my produc-recommendation-section file

instead of{ product.url }}.  i found {{ routes.product_recommendations_url }}

 

Do you know how i can change it?

 

 

Thanks for your help

 

 

Alexis_Théry
Shopify Partner
15 0 5

@batfink1989 

Thanks for you solution . my Url are clean now

Did you redirected all the long url to the canonical by a redirection on shopify? i have Thousands of url in GSC i am wondering how to manage them!

thanks

batfink1989
Shopify Partner
5 0 8

Hi @Alexis_Théry , sorry for the late reply. I'm pleased that my solution helped you.

 

Re the redirection of the URLs, I'm not sure Shopify allows you to redirect them, so that's the first thing I'd double check. In my case, I added a robots.txt rule to stop Google from crawling them in the first place. It's a bit hacky and not the perfect solution, but works in the context of Shopify:

Disallow: *?pr_prod_strat=*

 

Alexis_Théry
Shopify Partner
15 0 5

Hi @batfink1989 my question is do you notice in you search consol that url disapeared from your crawled but not indexate page?

nathanhuffhines
Excursionist
19 1 5

FWIW, I'm using the Expanse theme and all this is changed in the product-grid-item.liquid file.