Rich-text Reply

Conditional Activation for Meta Properties

danielpeskin 04-11-16
Accepted Solution

Conditional Activation for Meta Properties

Hey all,

 

I'm trying to get an experiment to activate conditionally when a specific meta property has a specific value. Running into issues after trying a few things. The meta property is called "og:availability", and I am trying to use a line of js to identify when the content reads "OutOfStock" and activate on those pages.

 

Here is an example out of stock page and you can see the meta tag in the source: http://fab.com/product/new-york-retro-ski-beanie-509544

 

Anyone have experience with this? Not sure what the code should be. I tried a couple things, but they were generally guesses based off the documentation - see below:

 

(OutOfStock).test($('meta[property=og:availability]').attr('content'))

 

also tried:

$('meta[property=og:availability]').attr('content').indexOf('OutOfStock') != -1

 

Any help would be much appreciated.

-----

Daniel


Digital Marketing Manager - mindbodygreen
Optiverse User Group Leader - NYC
JasonDahlin 04-11-16
 

Re: Conditional Activation for Meta Properties

Quotes are your friend.  Access the element this way:

(You can avoid the quotes insde the [  ] part only if the value contains no special characters)

 

$('meta[property="og:availability"]').attr('content').indexOf('OutOfStock')
--Jason Dahlin
Analytics and Testing Guru Smiley Happy
Experimentation Hero

Re: Conditional Activation for Meta Properties

So simple haha, I knew it was close. Thanks for helping out!
-----

Daniel


Digital Marketing Manager - mindbodygreen
Optiverse User Group Leader - NYC