Google Analytics Mobile Opt-Out -> Javascript in rich text editor

New Member
1 0 0

Hi,

I am aware of this post:

https://ecommerce.shopify.com/c/shopify-discussion/t/important-google-analytics-mobile-opt-out-updat...

I have done the same setup as shown in the discussion and used the solution provided.

But the following problems occurred:

the Code

<a href="[ga-optout]">foo</a>

changes into

<a href="%5Bga-optout%5D">foo</a>

after I placed it in the HTML code (Online store --> Pages --> "Privacy Policy" --> show HTML) and as soon as I save the changes. If I now visit the website and click the link I get redirected to the "404" error page. Also, the cookie which is supposed to be installed is not.

 

Is someone able to help me with this?

Thanks a lot!

Cheers:)

Linus

0 Likes
Highlighted
Shopify Partner
1 0 1

The '[' character is url encoded when savong the rich text editor content. I just came across the same issue. In lack of a more elegant solution you can do the following: 

Leave out the square brackets and use another unmistakable identifier like so:

<a href="my-analytics-optout-function">foo</a>

Then wrap the page.content variable on the page template like so:

{{ page.content | replace:'my-analytics-optout-function','javascript:gaOptout()' }}

This works for me.

1 Like