Skip to main content
Solved

Adding PX Product Mapper Feature to CC Like Button


Alistair FIeld
Forum|alt.badge.img+2

I would like to add the like button of the customer community to the product feature mapper of px.

 

Can I use the class in some way?

 

Best answer by rschlette

Hi Alistair. It’s not possible to add additional metadata to standard PX events like page view and click, but that’s where custom events come in.

 

In CC, we need to add event listeners to the Third Party Scripts “Before </Body>” section. From these event listeners, we can send PX custom events, including DOM attributes from the inSidedData object.

 

For example:

 

<!--begin PX Custom Event: Topic Like-->
<script>
    var likeButton = document.querySelector(".icon--thumb-up");
    if(likeButton!=null){
        likeButton.addEventListener("click", e => {
            aptrinsic('track','Like Button Clicked',{'title':inSidedData.content.topic.title,'type':inSidedData.content.topic.type});
        });
    }
</script>
<!--end PX Custom Event: Topic Like-->

 

That script looks for the like button on the page, and if that like button exists, listens for a click. When clicked, there is a PX custom event that sends the Title and Type attributes from inSidedData.content.topic

 

In PX we see these events like this:

https://share.zight.com/5zuk7EQQ

 

From there, raw custom events that flow to PX can be used in product mapper rules (custom event rules) and engagement audience logic (custom event rules). The custom events can also be accessed directly in Query Builder for reporting purposes (event type = custom event).

View original
Did you find this topic helpful?

7 replies

rschlette
Forum|alt.badge.img+2
  • Gainsight Employee ⭐️⭐️
  • 31 replies
  • April 7, 2025

Yes, you can use the selector:

.icon--thumb-up

or

[class=”icon--thumb-up”]

 

That’s the same selector written 2 different ways. That will track the article page likes, and the likes from article lists as well, assuming you keep the url scope in your product mapper rule open to those views, like subdomain.domain.com/*


Alistair FIeld
Forum|alt.badge.img+2
  • Author
  • Helper ⭐️⭐️⭐️
  • 253 replies
  • April 7, 2025

Awesome .. thanks ​@rschlette 

Am I also able to add the page title to the event?  I would like to see WHAT people are liking as well.

 


rschlette
Forum|alt.badge.img+2
  • Gainsight Employee ⭐️⭐️
  • 31 replies
  • Answer
  • April 7, 2025

Hi Alistair. It’s not possible to add additional metadata to standard PX events like page view and click, but that’s where custom events come in.

 

In CC, we need to add event listeners to the Third Party Scripts “Before </Body>” section. From these event listeners, we can send PX custom events, including DOM attributes from the inSidedData object.

 

For example:

 

<!--begin PX Custom Event: Topic Like-->
<script>
    var likeButton = document.querySelector(".icon--thumb-up");
    if(likeButton!=null){
        likeButton.addEventListener("click", e => {
            aptrinsic('track','Like Button Clicked',{'title':inSidedData.content.topic.title,'type':inSidedData.content.topic.type});
        });
    }
</script>
<!--end PX Custom Event: Topic Like-->

 

That script looks for the like button on the page, and if that like button exists, listens for a click. When clicked, there is a PX custom event that sends the Title and Type attributes from inSidedData.content.topic

 

In PX we see these events like this:

https://share.zight.com/5zuk7EQQ

 

From there, raw custom events that flow to PX can be used in product mapper rules (custom event rules) and engagement audience logic (custom event rules). The custom events can also be accessed directly in Query Builder for reporting purposes (event type = custom event).


Alistair FIeld
Forum|alt.badge.img+2
  • Author
  • Helper ⭐️⭐️⭐️
  • 253 replies
  • April 8, 2025

Awesome,

I have added the code provided

 

and created the custom event in PX, named Like Button Clicked.

Looking through the set up that should be it right?

I do not appear to be getting data sent through.

Am I missing something?

Thank for the expert guidance.


rschlette
Forum|alt.badge.img+2
  • Gainsight Employee ⭐️⭐️
  • 31 replies
  • April 8, 2025

It looks like there might be a copy/paste problem with the comments. Try deleting the open and close comments so that the <script> and </script> are the first and last elements in the code block


Alistair FIeld
Forum|alt.badge.img+2
  • Author
  • Helper ⭐️⭐️⭐️
  • 253 replies
  • April 8, 2025

I have made those changes and still no luck. If I paste the aptrinsic command into the console I get the event sent (minus the additional Attributes). 

So what I am seeing is the EventListener not hearing the click. 


rschlette
Forum|alt.badge.img+2
  • Gainsight Employee ⭐️⭐️
  • 31 replies
  • April 8, 2025

Yeah, that’s confusing. I checked the script on a public page in your community, and everything looks great. The query selector is getting set properly, and your event listener is exactly the same as the one I have running in a few community sites.

 

You might check with support if there’s some reason why this event isn’t firing. You can point them to https://robschlette-en-sandbox-community.insided.com/getting-started-in-the-community-2/we-re-launching-the-new-community-26 to see the same script in action


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings