1

I'm using Google Analytics for goal tracking and I need to run a custom script when Goal is complete. Does GA/GTM have any way to solve this? Thanks.

2
  • 2
    Can you supplement your question with things that you've attempted, or other resources you looked into? Commented Sep 17, 2015 at 18:37
  • For example, when user visit two specific pages (it will complete the goal) I need to send some data by CURL request to third party service. Commented Sep 18, 2015 at 18:23

1 Answer 1

1

The goal conversion is recorded serverside, so to be nitpicky you cannot track goal conversions on the client. However you can track the pageviews or events that are defined as goals in GA (this is not purely semantical, events and pageviews will happen once per hit, goal conversions happen once per session).

To track if the condition for a goal is met you can use a hit callback, a function that is executed once the tracking call has finished.

<script>
ga('send', 'event', {
  'eventCategory': 'Category',
  'eventAction': 'Action',
  'eventLabel': 'This is set as a goal!',
  'hitCallback': function() {
    alert("I'm a user function hear me roar!");
  }
});
</script>

The alert will be triggered once the event tracking is complete (obviously you would replace the alert with a call to your custom function).

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, but its not solve my problem. How about this: in Google Tag manager I create Custom HTML/JavaScript Tag, which triggered after specific pageviews. Does it mean that JS will be runned after pageviews?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.