Hi , Is there a way to count a button clicks using Visitor profile scripts? Because I want to use that count as audience and target the test. | Community
Skip to main content
New Participant
May 9, 2023
Solved

Hi , Is there a way to count a button clicks using Visitor profile scripts? Because I want to use that count as audience and target the test.

  • May 9, 2023
  • 3 replies
  • 1375 views
No text available
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by Matthew_Ravlich_ACG

Hi @subhad,

 

You can add a count for button clicks using custom code, profile scripts, and audience builder.

 

Here are the steps:

 

1) Add adobe.target.trackEvent to the close button you want a count for. Give it a unique name like "myCloseButton" or something like that.

2) Test that you see the delivery call firing when you click the close button using your browser's network tab.

3) Once you know the trackEvent is firing, navigate to the profile scripts section in the Adobe Target UI and click on "+ Create Script."

4) Enter the code that will count the close button click as follows:

 

 

 

if (mbox.name == 'myCloseButton') { return (user.get('clickedMyCloseButton') | 0) + 1; }

 

 

 

  • Make sure to name the profile script something like "clickedMyCloseButton" so you know what the profile script is for.
  • Make sure to save and activate the profile script.

5) Now, you can use the visitor profile within an audience. Once built, you can use it within a target activity.

 

I hope that helps.

 

Matthew Ravlich | ACG Digital | albertacg.com

3 replies

subhaDAuthor
New Participant
May 10, 2023

Thanks @matthew_ravlich_acg , its working.

Perrin_Ennen
New Participant
May 10, 2023

Hi @subhad,

I agree with @matthew_ravlich_acg - it was also saved in the user profile (possibly also with a max limit) and build an Audience from it accordingly.

Matthew_Ravlich_ACG
Matthew_Ravlich_ACGAccepted solution
New Participant
May 9, 2023

Hi @subhad,

 

You can add a count for button clicks using custom code, profile scripts, and audience builder.

 

Here are the steps:

 

1) Add adobe.target.trackEvent to the close button you want a count for. Give it a unique name like "myCloseButton" or something like that.

2) Test that you see the delivery call firing when you click the close button using your browser's network tab.

3) Once you know the trackEvent is firing, navigate to the profile scripts section in the Adobe Target UI and click on "+ Create Script."

4) Enter the code that will count the close button click as follows:

 

 

 

if (mbox.name == 'myCloseButton') { return (user.get('clickedMyCloseButton') | 0) + 1; }

 

 

 

  • Make sure to name the profile script something like "clickedMyCloseButton" so you know what the profile script is for.
  • Make sure to save and activate the profile script.

5) Now, you can use the visitor profile within an audience. Once built, you can use it within a target activity.

 

I hope that helps.

 

Matthew Ravlich | ACG Digital | albertacg.com